Worker cannot connect to docker swarm manager

0 votes

I have setup the docker swarm manager in one machine with IP 192.168.XXX.XXX by using this command :

docker swarm init --advertise-addr=192.168.XXX.XXX and I got this message :

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

docker swarm join --token SWMTKN-1- 
1eutz0k1vp37ztmiuxdnglka2 192.168.XXX.XXX:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
In other machine I tried the following command :
docker swarm join --token SWMTKN-1- 
1eutz0k1vp37ztmiuxdnglka2 192.168.XXX.XXX:2377
and the result was :
error response from daemon : rpc error : code = Unavailable desc = all 
SubConns are in TransientFailure, latest connection error: connection error 
: desc = "transport: Error while dialing dial tcp 192.168.XXX.XXX:2377 : 
connect: connection refused

Docker version :

Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:51 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     false
I also tried to provide my machine ip 192.168.XXX.XXX on the listen address in swarm init but I 
got the following error : 
docker swarm init --advertise-addr 192.168.XXX.XXX --listen-addr 192.168.XXX.XXX
Error response from daemon: manager stopped: failed to listen on remote API address: listen tcp 192.168.XXX.XXX: bind: cannot assign requested address

Jan 25, 2019 in Docker by Hamza
• 200 points

recategorized Feb 4, 2019 by Vardhan 3,623 views

Hey @Hamza, Try issuing appropriate ports through firewalld. Execute the following commands and let me the output:

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
I am using Windows 10 and I also added the following rules

netsh advfirewall firewall add rule name = "Cluster Management" dir=in action=allow protocol=TCP localport=2377

netsh advfirewall firewall add rule name = "Communication among nodes" dir=in action=allow protocol=TCP localport=7946

netsh advfirewall firewall add rule name = "Communication among nodes" dir=in action=allow protocol=UDP localport=7946

netsh advfirewall firewall add rule name = "Overlay traffic" dir=in action=allow protocol=UDP localport=4789

But still it didn't work
Ohh I missed that you are using windows.. Try stopping the firewall and restarting your docker.
Also, are you creating a single node cluster or a multinode cluster?
I have not made any docker-machine
Just started the manager in one machine
And tried to conect to it through other machine
So I think it would be multinode
And the firewall is already stopped ..
Do you have a single worker node or multiple worker nodes? If you have just one worker node, it means, it's a single node cluster else multinode cluster.

When you executed the init command what IP did you use? The one you found on ifconfig or 

docker-machine ls

I just used my machine public IP
When I run docker-machine ls it shows no machine
Am I supposed to make a docker machine on both manager and worker machines?
No @Hamza, you only need docker machine on the master. If docker machine ls shows no machine then your docker swarm init hasn't been successful. Reset the cluster and create a new fresh one again. Execute this command on the manager and worker nodes

docker swarm leave
I did the same thing but no docker machine in master
Instead I got one in executing
docker node ls
I tried to create docker machine using windows 10 hyper V but it also gets hang on waiting for ssh
So your docker swarm cluster master is on Linux and worker node on Windows?

Could you show me docker node ls output. Does it only show the master?

C:\WINDOWS\system32>docker node ls
ID                            HOSTNAME                STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
pha07j80echolrofazlhk4uzd *   linuxkit-00155d018101   Ready               Active              Leader              18.09.0
All on windows

What was your docker swarm init command?

In your init command, change the --advertise-addr port to 2377 and then join the worker nodes using the same port. 

The init command is mentioned in the question

Problem is port is not being listened
When I try to verify by netstat -a it doesn't show me the that port listened up

Yeah, the problem is the port is not getting into considered. Use your docker swarm init command as follows:

docker swarm init --advertise-addr
Didn't work :(
The easiest way out is, check what all ports are open/available and use those ports with --advertise-addr.
Hi @Hamza,

you need to establish the connection through ssh first

then only worker can join manage
Hi @Kalgl
I somehow managed to setup the swarm cluster now I have one manager and one worker
Now I am trying to create an overlay network to connect two containers  i.e Spark Master in manager node and Spark Worker in worker node.
Steps :
1. Made the overlay network in manager i.e docker create network --driver=overlay --attachable my-network
2. Then added these lines in docker-compose of Spark Master :
           - my-network
          external : true
3. Then I ran the command docker-compose up in manager and the service started successfully
4 But when I added the above lines in the docker-compose of Spark-worker in worker node then It couldn't start
by saying that "Could not found external network my-network"
Can you please guide me what am I doing wrong?

Inspect your network to check for any running contains. 

network inspect my-network

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Docker

0 votes
1 answer

swarm manager does not connect to nodes docker daemons on AWS

You first need to ssh into the ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 7,050 points
+2 votes
1 answer

Cannot connect to docker swarm service task

The id that command docker service ps <service> gives ...READ MORE

answered Sep 26, 2018 in Docker by Kalgi
• 52,350 points
+3 votes
4 answers

Not able to connect worker nodes to the swarm. Connection refused error

This definitely has to be a firewall issue. ...READ MORE

answered Apr 26, 2019 in Docker by Vaidya
+1 vote
1 answer

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Hi@akhtar, It seems the docker service is not ...READ MORE

answered Dec 24, 2020 in Docker by MD
• 95,440 points
0 votes
1 answer

How to add one worker node to the Docker swarm?

Hi@akhtar, You will get one token when you ...READ MORE

answered Dec 24, 2020 in Docker by MD
• 95,440 points
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP