The docker docs say that for swarm mode to work:
Open protocols and ports between the hosts
The following ports must be available. On some systems, these ports are open by default.
- TCP port 2377 for cluster management communications
- TCP and UDP port 7946 for communication among nodes
- UDP port 4789 for overlay network traffic
If you plan on creating an overlay network with encryption (--opt encrypted), you also need to ensure ip protocol 50 (ESP) traffic is allowed
Here is how one can test if these ports are indeed open. Use the nc command like follows:
On swarm manager:
siddjain@goldenrwr-ca0:~$ nc -zv localhost 2377
Connection to localhost 2377 port [tcp/*] succeeded!
siddjain@goldenrwr-ca0:~$ nc -zv localhost 7946
Connection to localhost 7946 port [tcp/*] succeeded!
siddjain@goldenrwr-ca0:~$ nc -uzv localhost 4789
Connection to localhost 4789 port [udp/*] succeeded!
siddjain@goldenrwr-ca0:~$ nc -uzv localhost 7946
Connection to localhost 7946 port [udp/*] succeeded!
On swarm worker note that port 2377 is refused:
siddjain@goldenrwr-peer0:~$ nc -zv localhost 2377
nc: connect to localhost port 2377 (tcp) failed: Connection refused
siddjain@goldenrwr-peer0:~$ nc -zv localhost 7946
Connection to localhost 7946 port [tcp/*] succeeded!
siddjain@goldenrwr-peer0:~$ nc -uzv localhost 4789
Connection to localhost 4789 port [udp/*] succeeded!
siddjain@goldenrwr-peer0:~$ nc -uzv localhost 7946
Connection to localhost 7946 port [udp/*] succeeded!