docker-swarm

Can't create Docker Swarm because of connection failure


  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.


Solution

    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