It looks like you are using docker-machine instead of docker.
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.