34

I think that command redirected $ docker commands to the docker machine. Now all my docker commands are giving me an error FATA[0000] Couldn't read ca cert... follwed by the path to the docker-machine I created. How can I fix my shell?

JAstuccio
  • 1,502
  • 2
  • 18
  • 20

5 Answers5

53

What you are looking for is:

eval "$(docker-machine env -u)"

It will unset the DOCKER_* variables.

For the record, here's the output of docker-machine env -u:

unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset DOCKER_MACHINE_NAME
David Gageot
  • 2,496
  • 1
  • 22
  • 13
  • 1
    I am getting the message _Host "default" does not exist_. – alvarez Nov 26 '15 at 15:47
  • 1
    Yes however above does not leave environment in condition prior to running docker-machine ... values prior to docker-machine are not saved for later ... it simply does an unset of docker-machine settings without restoring env settings to original settings ... we need to run a save-current-docker-settings before running docker-machine which post docker-machine and be used to restore original docker settings – Scott Stensland Sep 07 '16 at 15:54
  • Worked for me. I had switched to minikube docker context. I was able to go back to my 'regular' context by executing the 4 unset commands above. I am using Docker for mac community edition 18.06.1 on mac os High Sierra. – user674669 Oct 29 '18 at 22:13
  • Running this command gives a `command not found`, instead it refers to use `eval $(docker-machine env -u)` - so without the quotes. Perhaps things have changed over the years? – Florian Suess Jan 27 '19 at 22:28
  • When I try this on Windows, running `docker-machine env -u` is giving `'docker-machine' is not recognized as an internal or external command, operable program or batch file.`. – Panzercrisis Apr 08 '20 at 21:52
8

You could also restart your shell. This will drop the variables that minkube docker-env exports.

alisianoi
  • 2,003
  • 3
  • 31
  • 46
2

I can see that this is an old post but if someone else runs into this issue, who is new to docker like me this can help. By typing:

eval $(docker-machine env nameOfVm) 

you are setting your current shell to use docker in that docker-machine. You can check if you type docker-machine ls that under active tab, that status is changed from - to * for that machine. You can also check which machine is active by running docker-machine active.

If you want to undo eval, just run:

eval $(docker-machine env -u)

and it will unset variables for active machine (You don't have to specify the name of the machine). This is all under macOS but I think it should be same on linux as well. You can read more about this here: Docker documentation: docker-machine env

knile
  • 318
  • 3
  • 15
1

I had been searching for an answer to this for quite awhile. Shortly after posting the question on stackoverflow I realized typing in to the terminal the export commands docker gives on startup resolved my issue.

To connect the Docker client to the Docker daemon, please set:
export DOCKER_HOST=tcp:// some IP address
export DOCKER_CERT_PATH= some file path
export DOCKER_TLS_VERIFY=1
JAstuccio
  • 1,502
  • 2
  • 18
  • 20
0

All you have to do is run

docker-machine env machine-name

Then, copy and run the last segment in the output to set or remove the env variables.

Which looks like this in Windows :

eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env machine-name)

If it's set already, docker adds a "-u" at the tail to make the task easy.

like this in Windows :

eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env -u)

That's all.