Docker-swarm >> Cannot connect to docker endpoint

docker version 1.9.1 swarm version 1.0.1 

why when connecting 3 virtual machines (bridge network) to the swarm. Docker Info shows me all the nodes

The state is awaiting.

1 out of 3 hosts is a manager , all output from this host. I do not know where to look.

When running swarm --debug manage token://XXXXX

conclusion β†’

 *INFO[0000] Listening for HTTP addr=127.0.0.1:2375 proto=tcp DEBU[0000] Failed to validate pending node: Cannot connect to the docker engine endpoint Addr=10.32.1.38:2375 DEBU[0000] Failed to validate pending node: Cannot connect to the docker engine endpoint Addr=10.32.1.4:2375 DEBU[0000] Failed to validate pending node: Cannot connect to the docker engine endpoint Addr=10.32.1.33:2375 

Then

 root@ubuntu :~# ps -ef | grep swarm root 2158 1391 0 12:28 pts/2 00:00:00 swarm join token://xxxxxxx --addr 10.32.1.4:2375 root 2407 1213 0 13:57 pts/1 00:00:00 swarm manage token://xxxxxxx -H 0.0.0.0:4243 root 2413 1391 0 13:57 pts/2 00:00:00 grep --color=auto swarm 

Then

 root@ubuntu :~# swarm list token://xxxxxxxxxxx 10.32.1.4:2375 10.32.1.33:2375 10.32.1.38:2375 

Then

 root@ubuntu :~# ps -ef | grep docker root 2330 1 0 12:52 ? 00:00:00 /usr/bin/docker daemon root 2421 1391 0 14:10 pts/2 00:00:00 grep --color=auto docker 

heartbeat sorted - runs in the background, checked ports, name resolution, pingable from the manager.

+5
source share
5 answers

the docker daemon can listen on three different types of Socket: unix , tcp, and fd .

By default, the docker daemon just listens on a unix socket.

If you need to access the Docker daemon remotely, you need to enable the tcp socket.

When creating a swarm docker cluster, the swarm manager must remotely access swarm agent node docker daemons.

Therefore, you need to reconfigure the daemon

 vim /etc/default/docker 

Add the following line:

 DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock" 

Restart docker daemon

 sudo restart docker 

Thus, the remote docker demo can be accessed remotely.

Literature:

+5
source

I added the DOCKER_OPTS values ​​to / etc / default / docker

DOCKER_OPTS = "- H <> host IP <>: 2375 -H unix: ///var/run/docker.sock"

to be more precise, <Host IP β†’ is the same IP address of the host that you are editing the / etc / default / docker file.

Maybe this will help someone.

+3
source

Configuration methods vary depending on the host operating system on which Docker is running.

See Docker Daemon setup instructions (scroll down to find the host system):
Docker Configuration Documentation

I am running Red Hat Enterprise Linux 7.2 . So I followed the setup instructions for my OS from the link above and did the following:

  • mkdir /etc/systemd/system/docker.service.d
  • Create a docker.conf file
    vi /etc/systemd/system/docker.service.d/docker.conf
  • Add the following save to the docker.conf file.

     [Service] ExecStart= ExecStart=/usr/bin/docker daemon -D -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 
  • Reset Changes

     systemctl daemon-reload 
  • Reload docker

     systemctl restart docker 

The key configuration line (and where I deviated a bit from the documentation):

ExecStart=/usr/bin/docker daemon -D -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375

Skip this piece by piece:

  • /usr/bin/docker start with the docker binary
  • daemon run Docker Daemon
  • -D start in debug mode (not required)
  • -H unix:///var/run/docker.sock creates a standard docker socket
  • -H tcp://0.0.0.0:2375 creates a tcp Docker Socket that listens on port 2375 on all network interfaces.

After making these changes, I restarted my containers for the docker -H tcp://<IP_OF_SWARM_MASTER>:<PORT_YOU_TOLD_SWARM_MASTER_TO_LISTEN_ON> info flock (and in my case also the Consul containers) and ran docker -H tcp://<IP_OF_SWARM_MASTER>:<PORT_YOU_TOLD_SWARM_MASTER_TO_LISTEN_ON> info to find out if I get more error Cannot connect to the docker engine endpoint .

+2
source

Worked for me by adding the config /usr/lib/systemd/system/docker.service swarm to the workers service, where ExecStart is this line:

 ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 

Discard changes and restart Docker:

 sudo systemctl daemon-reload sudo systemctl restart docker.service 

But this approach is not protected; additional security configurations are needed.

+1
source

I am tired of the solutions mentioned in this thread. Editing / etc / default / docker did not help me.

Finally, that was the next decision.

Edit the file /lib/systemd/system/docker.service Find the line that starts with ExecStart and add -H = tcp: //0.0.0.0: 2375 so that it looks like

 ExecStart=/usr/bin/docker daemon -H=fd:// -H=tcp://0.0.0.0:2375 

Save Modified File Reload Docker Daemon

 systemctl daemon-reload 

Restart container

 sudo service docker restart 

Check if it works with the following command

 curl http://localhost:2375/images/json 

If everything is in order, the command should return JSON.

To verify remoteness, use the PC name or IP address of the Docker host.

0
source

All Articles