docker version 1.9.1
swarm version 1.0.1
why on connecting 3 VMs (bridged net) to swarm. "docker info" shows me all nodes
Status pending.
1 of 3 hosts is manager all output is from this host. I don't know where to look for.
On running swarm --debug manage token://XXXXX
output >>
*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 background, checked ports, name resolution, pingable from manager.
Configuration methods differ depending on the host OS on which you're running Docker.
See Docker Daemon configuration instructions (scroll down to find your host OS):
Docker Configuration Documentation
I'm running Red Hat Enterprise Linux 7.2 : therefore I followed config instructions for my OS form the link above and did the following:
mkdir /etc/systemd/system/docker.service.d
vi /etc/systemd/system/docker.service.d/docker.conf
Add the following to the docker.conf file then save.
Flush Changes
Restart Docker
The key line of configuration (and where I deviated slightly from the documentation) is:
ExecStart=/usr/bin/docker daemon -D -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
Let's go through this piece by piece:
/usr/bin/docker
start from the docker binarydaemon
start the Docker Daemon-D
start in debug mode (not required)-H unix:///var/run/docker.sock
creates the default Docker Socket-H tcp://0.0.0.0:2375
creates a tcp Docker Socket listening on port 2375 on all network interfacesAfter making these changes, I restarted my docker swarm containers (and in my case my Consul containers as well) and ran
docker -H tcp://<IP_OF_SWARM_MASTER>:<PORT_YOU_TOLD_SWARM_MASTER_TO_LISTEN_ON> info
to see if I was no longer getting theCannot connect to the docker engine endpoint
error.I have added DOCKER_OPTS values in /etc/default/docker
DOCKER_OPTS="-H <>host IP<>:2375 -H unix:///var/run/docker.sock"
to be more precise << Host IP >> is same host IP you editing your /etc/default/docker file.
Maybe it will help someone.
Worked for me by adding in swarm workers service config
/usr/lib/systemd/system/docker.service
whereExecStart
is located this line:Flush changes and restart Docker:
But this approach is unprotected, need additional security configs.
The docker daemon can listen on three different types of Socket: unix, tcp and fd.
By default, docker daemon just listen on unix socket.
If you need to access the Docker daemon remotely, you need to enable the tcp socket.
When creating docker swarm cluster, the swarm manager need to access the docker daemon of swarm agent nodes remotely.
Therefore, you need to re-configure the docker daemon
Add following line:
Restart docker daemon
By doing this, the docker daemon can be accessed remotely.
References:
I tired the solutions mentioned in this thread. Editing /etc/default/docker did not work for me.
Finally what was the following solution.
Edit /lib/systemd/system/docker.service file Find the line which starts with ExecStart and add -H=tcp://0.0.0.0:2375 to make it look like
Save the Modified File Reload the docker daemon
Restart the container
Test if it is working by using following command
If everything is fine below command should return a JSON.
To test remotely, use the PC name or IP address of Docker Host.