What does the DOCKER_HOST variable do?

872    Asked by AishwaryaJhadav in Devops , Asked on Jun 15, 2021

 Hey there, I have just started learning about docker. I am using Boot2Docker with OSX. I am getting an error logging into it :

To connect the Docker client to the Docker daemon, please set
export DOCKER_HOST=tcp://192.168.59.103:2375
Weirdly enough the basic Docker commands work okay.
like : docker run hello-world
Plus the installation guide isn't that helpful :
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.
What I'm not clear on:
What is the docker "client"?
What is the docker "daemon"?
What is the docker "host"? 

Answered by Akansha Chawla

To solve $docker_host you can go through the below-mentioned solution:

In this case, Client is the docker command in OSX

Host is basically the boot2docker virtual machine.

Daemon is basically a service running in the background inside boot2docker.

When you type in the docker commands they work because the terminal window that comes up already has the DOKCER_HOST set . You will be required to set this variable in some other windows.

another thing you can do is use the below command:

$ export DOCKER_HOST=tcp://192.168.59.103:2375
This should set the DOCKER_HOST variable,but it would be better to try this:
$ $(boot2docker shellinit)
$ docker run hello-world
Hello from Docker. [...]
Trying to run boot2dockerr shellinit gives back a group of bash commands that set the environment variable :
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/ddavison/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
Just run $(boot2docker shellinit) it will generate all those commands
and then just run those commands .

Hope this helps :smile:



Your Answer

Interviews

Parent Categories