skip to Main Content
  1. Target: Creating a Docker Swarm

  2. Condition:

    • Host A: Ubuntu 23.10
    • Host B: Mac Sonoma 14.1.2
  3. Operation:

    • In Host A:
      docker swarm init
      
    • In Host B:
      docker swarm join --token SWMTKN-1-3o2m78qf57hy2zikfx8p2yc7hrn63edlmlixwrq7bh28xws7zx-9oirn0wh3mbrdui3kcwytl560 192.168.65.9:2377
      
  4. Error:

    Error response from daemon: rpc error: code = Unavailable desc = connection error:
    desc = "transport: Error while dialing dial tcp 192.168.65.9:2377: connect: no route to host"
    
  5. What I’ve done so far:

    • Installed firewalld on Ubuntu Host A, but for unknown reason it caused system crash. I guess this is because Ubuntu 23.10 doesn’t support firewalld anymore.
    • Use ufw command to open communication port on Ubuntu Host A, but it doesn’t work.
  6. Asking for help: I saw other people can easily run the "docker swarm join" command in the tutorial. Why I got this problem? Any one can help me out? Really appreciate your help.

2

Answers


  1. You need to open several ports for the communication (On A as well ass B hosts):

    As Docker documentations says:

    • Port 2377 TCP for communication with and between manager nodes
    • Port 7946 TCP/UDP for overlay network node discovery
    • Port 4789 UDP (configurable) for overlay network traffic

    Furthermore:

    • Port 2376 TCP for secure Docker client communication.

    Set UFW config (Or disable the UFW as you mentioned in your question):

    ufw allow 22/tcp
    ufw allow 2376/tcp
    ufw allow 2377/tcp
    ufw allow 7946/tcp
    ufw allow 7946/udp
    ufw allow 4789/udp
    ufw reload
    ufw enable
    systemctl restart docker
    

    You can check the IpTables configuration as well based on this documentation: https://www.digitalocean.com/community/tutorials/how-to-configure-the-linux-firewall-for-docker-swarm-on-ubuntu-16-04

    BUT, The "Docker for Mac" uses different networking as Linux based and that can cause turbulence in Docker Swarm. Here is a ticket for it: https://github.com/moby/swarmkit/issues/1146#issuecomment-231412874

    Based on the above ticket the Mac can run only single-node Swarm right now. (I didn’t find fix for it)

    Login or Signup to reply.
    1. Ensure that both are connected to a local network (connected inside a network)

    You need to connect machines together verify that by ping (if you are using a firewall then ping ICMP packets wont work). do a curl request from A to B

    1. Check firewall status ufw status if its status: inactive then its not a problem else disable the firewall(DISCLAIMER: may become a security issue) or Open only specific ports like 2376, 4789, 2377, 7946.
    ufw allow 7946/tcp
    ufw allow 7946/udp
    ufw allow 2376/tcp
    ufw allow 4789/udp
    ufw allow 2377/tcp
    

    sudo ufw reload

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search