-2

I had my docker env variables set like this:

set -gx DOCKER_TLS_VERIFY "1";
set -gx DOCKER_HOST "tcp://xxx.xxx.xxx.xxx:2376";
set -gx DOCKER_CERT_PATH "/home/me/.docker/machine/machines/myhost";
set -gx DOCKER_MACHINE_NAME "myhost";

When I tried running docker-compose up, I got this error:

backports.ssl_match_hostname.CertificateError: hostname 'xxx.xxx.xxx.xxx' doesn't match 'localhost'

But then I happened upon this blog post that recommended that I set my local dns to point localhost to xxx.xxx.xxx.xxx. And it worked.

Why did this solution work? And more importantly, what can I do to not use it again?

  • Why do you not use the default docker variables? What OS do you use? – 030 Dec 30 '17 at 10:44
  • I am. those are the default docker env variables. – dopatraman Dec 30 '17 at 22:10
1

It looks like you are using instead of .

https://docs.docker.com/machine/get-started/#create-a-machine

Get the environment commands for your new VM.

As noted in the output of the docker-machine create command, you need to tell Docker to talk to the new machine. You can do this with the docker-machine env command.

 $ docker-machine env default
 export DOCKER_TLS_VERIFY="1"
 export DOCKER_HOST="tcp://172.16.62.130:2376"
 export DOCKER_CERT_PATH="/Users/<yourusername>/.docker/machine/machines/default"
 export DOCKER_MACHINE_NAME="default"
 # Run this command to configure your shell:
 # eval "$(docker-machine env default)"

Why did this solution work?

According to this documentation the variables have to be set over and over again.

Unset environment variables in the current shell

You might want to use the current shell to connect to a different Docker Engine. This would be the case if, for example, you are running Docker for Mac concurrent with Docker Toolbox and want to talk to two different Docker Engines, or running swarms on Docker Cloud and want to switch between managing the swarm and using Docker hosts. In both scenarios, you have the option to switch the environment for the current shell to talk to different Docker engines.

Run env|grep DOCKER to check whether DOCKER environment variables are set.

$ env | grep DOCKER
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_MACHINE_NAME=default
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/Users/victoriabialas/.docker/machine/machines/default

If it returns output (as shown in the example), you can unset the DOCKER environment variables.

Use one of two methods to unset DOCKER environment variables in the current shell.

    Run the unset command on the following DOCKER environment variables.

    unset DOCKER_TLS_VERIFY
    unset DOCKER_CERT_PATH
    unset DOCKER_MACHINE_NAME
    unset DOCKER_HOST

    Alternatively, run a shortcut command docker-machine env -u to show the command you need to run to unset all DOCKER variables:

    $ docker-machine env -u
    unset DOCKER_TLS_VERIFY
    unset DOCKER_HOST
    unset DOCKER_CERT_PATH
    unset DOCKER_MACHINE_NAME
    # Run this command to configure your shell:
    # eval $(docker-machine env -u)

    Run eval $(docker-machine env -u) to unset all DOCKER variables in the current shell.

Now, after running either of the above commands, this command should return no output.

 $ env | grep DOCKER

If you are running Docker for Mac, you can run Docker commands to talk to the Docker Engine installed with that app.

If you are running swarms on Docker Cloud, you can re-run the export command you used to connect to the swarm.

Since Docker for Windows is incompatible with Toolbox, this scenario isn’t applicable because Docker for Windows uses the Docker

Engine and Docker Machine that come with it.

  • Thanks for the response! Unfortunately I need to use docker-machine to manage remote hosts. The issue here does not seem to be setting the environment variables. Instead it seems to be the way docker interacts with my local DNS lookup. From what I can tell, the backports python package (that shipped with docker-compose 1.8 atleast) depends on the hostname localhost being set. This is the main source of confusion imo. – dopatraman Dec 30 '17 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.