Search code examples
amazon-web-servicesdockeramazon-ec2docker-swarm

how to connect docker swarm worker to swarm manager - AWS EC2


I am unable to connect my docker worker to docker swam manager.

I have created multiple aws EC2 instances and have made one of them as a manager docker swarm init --listen-addr 0.0.0.0:2377 and trying to connect it via other EC2 instances docker swarm join 0.0.0.0:2377 as a worker, But it gives me an error.

 "Error response from daemon: Timeout was reached before node joined`. 
The attempt to join the swarm will continue in the background".

I need my docker swarm manager to list docker node ls all the nodes including manager and workers.


Solution

  • To resolve this problem I needed to expose respective ports from both Docker Worker and Docker Manager instances.

    I discovered some information while resolving this question,

    TCP Port 2377 is a Default port used for communication so add custom tcp rule for port 2377 in security group of aws EC2.

    TCP port 2376 for secure Docker client communication. This port is required for Docker Machine to work. Docker Machine is used to orchestrate Docker hosts.

    TCP port 2377 This port is used for communication between the nodes of a Docker Swarm or cluster. It only needs to be opened on manager nodes.

    TCP and UDP port 7946 for communication among nodes (container network discovery).

    UDP port 4789 for overlay network traffic (container ingress networking).

    Kindly Note: Aside from those ports, port 22 (for SSH traffic) and any other ports needed for specific services to run on the cluster have to be open.