Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Workers unable to connect to Swarm on AWS EC2

I am new to AWS EC2,

Objective: To create 3 instances of Ubuntu machines on EC2 and initialise Swarm on the first instance and add the other 2 instances as workers to the Swarm.

Error: Swarm initialization works fine but adding workers to the swarm throws an error

~$ docker swarm join --token SWMTKN-1-4yquvx0xihdhcv0m1vmxmbq4q45hoanm9ig00pue7opx3dhc1s-2ybrjxx97mpjyo351sx8jyisp 172.31.31.41:2377
 Error response from daemon: Timeout was reached before node was 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.

~$ docker info
*****
Swarm: error
 NodeID:
 Error: rpc error: code = DeadlineExceeded desc = context deadline exceeded
 Is Manager: false
******

I have looked at the relevant questions on stackoverflow (Docker 1.12.1: after swarm init, workers unable to join swarm) but those solutions are not working in my case

How do I enable my other 2 instances to join the swarm

like image 680
Shivanand T Avatar asked Jan 29 '23 15:01

Shivanand T


1 Answers

This looks like a issue with your security settings. Make sure all the required ports are open

On Managers:

Custom TCP Rule TCP 2377    swarm + remote mgmt
Custom TCP Rule TCP 7946    swarm
Custom UDP Rule UDP 7946    swarm
Custom UDP Rule UDP 4789    swarm

On workers

Custom TCP Rule TCP 7946    swarm
Custom UDP Rule UDP 7946    swarm
Custom UDP Rule UDP 4789    swarm

See below for more details

https://gist.github.com/BretFisher/7233b7ecf14bc49eb47715bbeb2a2769

Also check ufw status, iptables -S and sestatus to make sure any of those are not blocking the access

like image 164
Tarun Lalwani Avatar answered Feb 06 '23 07:02

Tarun Lalwani