Docker Community Forums

Share and learn in the Docker community.

Cannot connect to remote daemon, but can connect to remote daemon in container

I am trying to connect to a docker daemon on a different machine. I have to VM A and B. I want to run the daemon on VM A and connect to it from VM B.

For now, I’m not interested in setting-up TLS, or anything like that.

If I launch the daemon on VM B using this:

dockerd -H tcp://0.0.0.0:2375

And then try to talk to it from VM A:

curl x.x.x.x:2375/version
docker -H tcp://x.x.x.x:2375 ps

It just hangs for some time and then throw an error.

But if I launch a daemon inside a docker on VM B:

# Start the docker on the standard socket:
dockerd

docker run --privileged -p 2375:2375 docker:dind dockerd -H tcp://0.0.0.0:2375

I can communicate with it from VM A without issue:

curl x.x.x.x:2375/version  # Ok
docker -H tcp://x.x.x.x:2375 ps  # Ok

Is there any reason why I could not connect to the daemon when started directly from the VM?

In order to connect to a remote Daemon running on any server machine please follow the below steps. Identify the Host machine where the Docker Client is running. If the Docker Client Machine is a Linux Machine. Please run the below command that connects to the remote docker Daemon.

export DOCKER_HOST=ssh://administrator@10.242.41.222
The above command will establish the ssh connection to the remote machine and all the docker command get executed on the remote machine.

If the Docker Client Machine is a Windows Machine. Please run the below command to obtain the same result as above.

$env:DOCKER_HOST=“ssh://administrator@10.242.41.222”
If one wants the docker client to use the old Docker daemon running on the client server. Please reset the value of the environment variable to empty.

In WIN : $env:DOCKER_HOST=" " In Linux : export DOCKER_HOST=’ ’

Thanks for your reply.

I do not want to connect using SSH, I want to connect using TCP/HTTP, and I don’t want to export the DOCKER_HOST variable because I also have a docker daemon running on the client.

I already now how to connect to a remote Docker daemon since, as I wrote, I’m already doing it. What I want is to know why I cannot contact the remote Docker daemon but I can contact a Docker daemon running inside a container on the remote VM.