I'm new to Docker, using Boot2Docker on OSX. After booting it, this message is given:
To connect the Docker client to the Docker daemon, please set
export DOCKER_HOST=tcp://192.168.59.103:2375
Yet even without it, basic Docker commands (eg, docker run hello-world
) work fine.
The install instructions aren't very informative:
Note: If you see a message in the terminal that looks something like this:
To connect the Docker client to the Docker daemon, please set:
export DOCKER_HOST=tcp://192.168.59.103:2375
you can safely set the evironment variable as instructed.
Knowing that it's "safe" doesn't say why it's useful.
What I'm not clear on:
- What is the docker "client"?
- What is the docker "daemon"?
- What is the docker "host"? (The Boot2Docker VM itself?)
Upon investigation, it's also worth noting that when you want to start using docker in a new terminal window, the correct command is:
I had tested these commands:
Notice that docker info returned that same error. however.. when using
$(boot2docker shellinit)
...It points to the docker host! I followed these steps:
See:
http://docs.docker.com/userguide/dockerizing/
Ok, I think I got it.
The client is the
docker
command installed into OS X.The host is the Boot2Docker VM.
The daemon is a background service running inside Boot2Docker.
This variable tells the client how to connect to the daemon.
When starting Boot2Docker, the terminal window that pops up already has
DOCKER_HOST
set, so that's whydocker
commands work. However, to run Docker commands in other terminal windows, you need to set this variable in those windows.Failing to set it gives a message like this:
One way to fix that would be to simply do this:
But, as pointed out by others, it's better to do this:
To spell out this possibly non-intuitive Bash command, running
boot2docker shellinit
returns a set of Bash commands that set environment variables:Hence running
$(boot2docker shellinit)
generates those commands, and then runs them.