Reputation: 33
I have been trying to join a worker to a manager node but I'm not able to. My manager node is running on my personal laptop which runs ubuntu 18. The worker node im trying to make is on an ec2 instance which also runs ubuntu. To create the manager node I wrote this and created it successfully.
docker swarm init --advertise-addr 192.168.10.10:2377
which returns:
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-2ywtsoky86nabtq10try9jwnap7j3guigh1hywcfyb5u4tv0m5-a8zwarpuk1j79hy60yke2hrbk 192.168.10.10:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
After that i go to my ec2 instance ubuntu and run this command:
docker swarm join --token SWMTKN-1-2ywtsoky86nabtq10try9jwnap7j3guigh1hywcfyb5u4tv0m5-a8zwarpuk1j79hy60yke2hrbk 192.168.10.10:2377
which shows me this error:
Error response from daemon: Timeout was reached before node joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node.
I've tried allowing the port 2377 on firewall on both systems and restarting it but it still doesn't work. Does anyone know the reason its not connecting?
Update 1: I've also tried to match the time zones of both systems but that doesn't work either
Thanks
Upvotes: 2
Views: 4246
Reputation: 65
While the above answers work, the better way to make a docker swarm work on EC2 instances is to edit Inbound Rules in the Security Group of the Manager node.
The following ports are needed:
TCP on 2377 - For communication with and between manager nodes
TCP/UDP on 7946 - For overlay network node discovery
UDP on 4789 - For overlay network traffic
Open protocols and ports between the hosts
Upvotes: 0
Reputation: 231
I had the same problem with this. first, try to connect to the server with swarm enabled by telnet from the worker node server. In my problem, this was not working, which meant that the error I was getting when I ran the docker swarm join command was related to the firewall. As a solution, I allowed 2377/TCP port in the firewall on the server that will be the first worker node. But this was not the solution. For the second time, I allowed 2377/TCP port in the firewall on the server with the manager node. In this case, the worker node was able to join the swarm.
ufw allow 2377/tcp
Upvotes: 0
Reputation: 11
If you are running on some public cloud, make sure that access lists in EC2 security groups and allow connections between hosts on that port.
Upvotes: 1
Reputation: 21
you can run netstat -tulpn | grep LISTEN
to see all ports you need to allow. In my case it was:
ufw allow 22/tcp &&
ufw allow 53/tcp &&
ufw allow 2377/tcp &&
ufw allow 7946/tcp &&
ufw allow 7946/udp &&
ufw allow 4789/udp &&
ufw reload &&
ufw enable &&
systemctl restart docker
Upvotes: 2