3

I installed DockerToolbox 1.11.1 on my Mac OS 10.11 and it does start docker via Kinematic and if I click Docker CLI it wills start a terminal where docker is properly running (docker version returns info and success).

Still, If I try to do the same from normal console it does fail to detect docker and I do want to have docker available in any console window, starting it at login time, automatically or on demand. Still, once started I expect to be able to use it from any console.

I guess that this part was missing from the tutorials and I would like to find a solution for it. How can I do this?

sorin
  • 161,544
  • 178
  • 535
  • 806

2 Answers2

1

This is what docker machine is for. Your docker instance is running in a virtual machine, and you have to set a few environment variables to connect to it(DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH and DOCKER_MACHINE_NAME) . If you run eval $(docker-machine env [machine name]) this will set those variables automatically for you assuming the VM is up. You could then put that line into your bash profile for automatic setup.

Check out the docs here https://docs.docker.com/machine/overview/

Also, there is a native version of Docker for OSX (currently in limited beta) which removes the need for docker machine, so hopefully in the near future none of this will be necessary.

tpbowden
  • 2,040
  • 15
  • 22
  • Thanks, based on your feedback I was able to come up with some generic code see http://stackoverflow.com/a/37115304/99834 – sorin May 09 '16 at 12:01
0

I was able to come up with some code that works across all tested platforms, including OS X:

docker version > /dev/null || {
# that's in case docker machines is the the current one (OS X)
eval "$(docker-machine env default)"
}
# keep this here, it will return an error code if docker is not usable
docker version
sorin
  • 161,544
  • 178
  • 535
  • 806