I'm trying to connect a docker daemon from a client to a remote host via TCP but I'm getting this error:
docker -H tcp://{{HOST_IP}}:2375 ps
Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
What could be possible reasons for that? What is a proper debugging approach for finding a solution?
- System: Ubuntu 18.04 (client and host)
- ufw: enabled for all incoming & outgoing (for testing purposes)
- access rights: working with root on client & host
WHAT I DID
On host:
systemctl edit docker.service
Add and save these lines:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375
Reload daemon:
systemctl daemon-reload
Restart docker:
systemctl restart docker.service
Check if it worked:
netstat -lntp | grep dockerd
Result:
tcp 0 0 127.0.0.1:2375 0.0.0.0:* LISTEN 3758/dockerd
Test with docker:
docker -H tcp://127.0.0.1:2375 ps
Everything worked on the host. However, when I'm trying to connect from the client with the remote host I'm getting an error.
On client:
docker -H tcp://{{HOST_IP}}:2375 ps
Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
Connecting via ssh works:
docker -H ssh://root@{{HOST_IP}} ps
docker -H ... -v /:/host busybox cat /host/etc/shadow
to read back the encrypted user passwords on that host, as the least damaging thing you could do.) Remove thatdockerd -H
option immediately and consider whether you might need to reinstall the system. – Unaccountedfor