Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to the Docker daemon (port 2375)

Tags:

linux

docker

I have installed Docker on Ubuntu 16.04 server, using the manual on this page: https://docs.docker.com/cs-engine/1.13/, so, using these steps:

curl -fsSL 'https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e' | sudo apt-key add -
sudo add-apt-repository    "deb https://packages.docker.com/1.13/apt/repo/ \
ubuntu-$(lsb_release -cs) \
main"

sudo apt-get update
sudo apt-get -y install docker-engine

I have installed it on two servers and I need them to see each other, I needed to let Docker daemon listen on port 2375 (probably doesn't matter, but using this manual: https://github.com/yeasy/cello/blob/master/docs/deployment.md)

So I created the conf file:

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vim /etc/systemd/system/docker.service.d/override.conf

Added this to the override.conf:

[Service]
DOCKER_OPTS="$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --api-cors-header='*' --default-ulimit=nofile=8192:16384 --default-ulimit=nproc=8192:16384"
EnvironmentFile=-/etc/default/docker
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS

Then:

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker.service

Tested the connection between servers like this:

$ docker -H 10.101.35.61:2375 version

The response:

Client:
 Version:      1.13.1-cs4
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   e46aec0
 Built:        Mon May 22 18:46:40 2017
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon at tcp://10.101.35.61:2375. Is the docker daemon running?

Tried restarting the server, same problem. Tried to run with sudo. Tried adding the user to group docker:

sudo usermod -aG docker $USER

Didn't help. I have disabled firewall on both servers. When I check the ports open on the server with sudo lsof -i, I can't see anything listening to port 2375 - I am guessing Docker should be listening to it?

like image 792
neuromouse Avatar asked Jun 07 '17 11:06

neuromouse


People also ask

How do I get Docker daemon port?

Locally, the Docker client uses this socket to communicate with the daemon. -H tcp://0.0.0.0:2376 makes the daemon available via any network interface on port 2376. This port needs to be opened in the security groups (and restricted to a white list of IP addresses if possible) so a remote client can access the daemon.

What port does Docker daemon run on?

It is conventional to use port 2375 for un-encrypted, and port 2376 for encrypted communication with the daemon.

How do you expose daemon on TCP localhost 2375 without TLS?

If you are using Docker Desktop and want to connect through the TCP socket, enable the Expose daemon on tcp://localhost:2375 without TLS option in the General section of your Docker settings. Then set Engine API URL to tcp://localhost:2375 .


1 Answers

Try the config file in this location, create it if it does not exist:

/etc/docker/daemon.json

Put this and restart the docker service:

{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}

You can add more configs, documented here.

like image 60
Robert Avatar answered Oct 21 '22 16:10

Robert