简体   繁体   中英

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.

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.

You need to use the real ip address in the docker swarm join command.

The "0.0.0.0" is not a real ip-address, it's an alias for "all (local) ip-addresses", it's not something you can connect to.

1.run the command in the master node: docker swarm join-token worker

2.and than run the command obtained from above step

example:

root@ubuntu:~# docker swarm join-token worker To add a worker to this swarm, run the following command:

docker swarm join --token SWMTKN-1-0akniaryx9xg8mmb08rbd42kwntigfkyk33vt7ac0wrehn58mk-5voo7jfl3kl40yl4cmvf16lgt 10.0.10.4:2377

root@ubuntu:~#

run on worker node: docker swarm join --token SWMTKN-1-0akniaryx9xg8mmb08rbd42kwntigfkyk33vt7ac0wrehn58mk-5voo7jfl3kl40yl4cmvf16lgt 10.0.10.4:2377

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM