Docker Community Forums

Share and learn in the Docker community.

Swarm init issue

docker

(Geraldliu) #1

Hi
I use the below command to init swarm on leader machine:

sudo docker swarm init --advertise-addr 172.19.187.96:2800 --listen-addr 172.19.187.96:2801
Swarm initialized: current node (d0xlmdxm6ew5xis1046yze7c6) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join \
--token SWMTKN-1-57yenz8gevqjr5voo8j58oswwbnojtoffdzd24p91kxbbrmxa3-arphlwto9tk9ncwj00nkv7l8h \
172.19.187.96:2800

Then, I follow the resulted commmand to make the node join in the network. But it failed:
sudo docker swarm join --token SWMTKN-1-57yenz8gevqjr5voo8j58oswwbnojtoffdzd24p91kxbbrmxa3-arphlwto9tk9ncwj00nkv7l8h 172.19.187.96:2800
Error response from daemon: rpc error: code = 14 desc = grpc: the connection is unavailable

if I changed the port from 2800 to 2801 in the command, it is OK.
sudo docker swarm join --token SWMTKN-1-57yenz8gevqjr5voo8j58oswwbnojtoffdzd24p91kxbbrmxa3-arphlwto9tk9ncwj00nkv7l8h 172.19.187.96:2801
This node joined a swarm as a worker.

I felt the strange that the swarm init command gave a result for node join it but user could not follow the result to do it.
BTW, I found there is no processes monitor the 2800 port at that time.

is the docker bug? could some guys give some suggestion?

Thanks.


(Geraldliu) #2

some guys know this issue?


(Adyanthaya17ash) #3

Hi,

I am having the same issue. I installed the main UCP on one machine but while trying to add a replica node to the cluster I am getting the error:

docker swarm join --token SWMTKN-1-38ktpioszt6156rdryztshyzbn5iqkvtmnmjj4la6i0v5m82pa-41n2sznls1ez0hc47a5a06f6n 10.211.x.x:2377
Error response from daemon: rpc error: code = 14 desc = grpc: the connection is unavailable.


(Azaars) #4

Try to specify IP address only on both --advertise-addr and --listen-addr.


(Gilgameshs) #5

+1 some issue as yours


(Chenwenwen) #6

I meet the same problem, and solve this by changing the --advertise-addr ip with docker_gwbridge ip.


(Smbiswal) #7

I faced the same problem.From firewall logs it looked like the firewall was blocking the swarm port.
After disabling the firewall it worked fine.


(Arul Selvan) #8

The --listen-addr and --advertise-addr are roughly the same except for one major difference; The former allows you to bind on all of your interfaces (it is the default) while the later is meant for specific, externally reachable interface. You only need to use --listen-addr when you have multiple interfaces and you do not want swarm mode traffic on all of them.

Having said that, in your case you provided both (which is redundant since the IPs are the same), however, you also listed 2 different ports for one single service. You can’t have the node management service on two different ports, so docker chose one of the port to listen. It would be nice if docker provided the correct join message and a warning … anyways, that is the reason you can’t connect on 2800. I would use just the --advertise-addr and default port 2377 (unless default port is taken) and add --listen-addr only if you have multiple interfaces and a business case to segregate traffic/services.


(Fanjieqi) #9

Hey guys, I just init the swarm in my current mac, which have the same issue with you.

$ docker swarm init --advertise-addr 192.168.99.100

If I create a manager1 firstly, then ssh into it and init the swarm, it works.

$ docker-machine create manager1
$ docker-machine ip manager1
# 192.168.99.104
$ docker-machine ssh manager1
docker@manager1:~$ docker swarm init --advertise-addr 192.168.99.104

Now, I create a worker1, then ssh into it and join it to the swarm cluster, it works perfectly.

$ docker-machine create -d virtualbox worker1
$ docker-machine ssh worker1
docker@worker1:~$ docker swarm join --token SWMTKN-1-1s06e6ubid2axcj3h9bo06smlj32jhqp74pj1wkmflb3f0x5pi-cde5dm1xdzo3eum3s7lrj96aa 192.168.99.104:2377

So, the problem is that we might not init the swarm in our current macos, but in a manager we create.


(Natereid) #10

Run this command on each machine you’re using in the cluster (copy and paste everything below at one time[This is for dev use only]:

sudo firewall-cmd --add-port=2376/tcp --permanent && sudo firewall-cmd --add-port=2377/tcp --permanent && sudo firewall-cmd --add-port=7946/tcp --permanent && sudo firewall-cmd --add-port=7946/udp --permanent && sudo firewall-cmd --add-port=4789/udp --permanent && firewall-cmd --reload && Systemctl restart docker


(Tonyjonah) #11

Thanks this worked for me


(Darren Halprin) #12

After hours of pulling my hair out, I have finally gotten to the bottom of this issue and your solution lucked upon the answer without actually realising where the problem lay.

The issue is that the output of the previous command provided by docker-machine has an error.

Here’s what I typed and the response.

bash-3.2$ docker-machine ssh myvm1 “docker swarm init --advertise-addr 192.168.99.100”
Swarm initialized: current node (h7c9rk1a2ya4k2e5rjgnkpani) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join --token SWMTKN-1-6aqioo5188tneazemz37vqifq89tlkaaalm82xo3zsb5grf04n-cqc6ht42rrvt3qd6gk8eschuu 192.168.99.100:2377

Notice above that the command it gives you to enter to join the swarm includes the port number (2377) after the I.P. Address. This is the error. Instead enter up to the end of the IP address without the port number and it works as per below. Also, be sure to leave off the port number when creating the manager as well. It defaults to the correct port number of 2377.

bash-3.2$ docker-machine ssh myvm2 “docker swarm join --token SWMTKN-1-6aqioo5188tneazemz37vqifq89tlkaaalm82xo3zsb5grf04n-cqc6ht42rrvt3qd6gk8eschuu 192.168.99.100”

This node joined a swarm as a worker.

bash-3.2$

So you got there by splitting the command into it’s two parts, the SSH into the VM and then the Docker command, but you in fact also did not add the port and so it worked.