Docker Community Forums

Share and learn in the Docker community.

Docker Swarm overlay network - containers can't communicate

Hello everyone,

Tl;dr: Docker swarm containers using overlay network can’t ping eachother

I am trying to create a swarm, which includes my Desktop (Windows which Docker Desktop) and a Ubuntu VM (Swarm manager, on my Desktop PC).

Creating the swarm and joining it works fine. I proceded to create an attachable overlay network, which should span all my nodes using the overlay driver. I have created a random nginx service, using global mode and my overlay network to make the network available on all my nodes.

To test the connectivity I created two ubuntu containers (One on Ubuntu, one on my Windows) and joined them to the network. The Problem is that the containers can’t ping eachother.
I have also opened the required ports for swarm (2376, 2377, 7946, 4789) on my Windows and Ubuntu VM.

Do you know how I can make the connection work?

I didn’t use services to test the connectivity. I created normal containers and tried to ping the IP of the other container, which only worked if they were on the same host.

I only created a global nginx service to make the overlay network available on all nodes.

If I understand you, you have created a swarm with an attachable network. This swarm swarm has an Nginx service runing in global mode. And you created 2 containers outside the swarm using the same attachable network. Is it correct?

Yes. The only purpose of the two containers is to ping eachother over the swarm network, which stretches accross two pcs.

And the only purpose of the nginx service is to make the overlay network available on all nodes. As nodes don’t seem to see all swarm networks automagically.

This whole setup is just for testing purposes only. Later on I will create a proper setup.

Creating the two containers via a service doesn’t work either.

When I use two linux vms on my desktop the connection works. Super strange.

Which containers are you using?
Are you using Windows containers on your Desktop PC and Linux containers on your Ubuntu VM?
If it’s so, could you try to use Linux containers on your Desktop PC (windows) instead? Sometimes, it works.

From the Docker Desktop menu, you can toggle which daemon (Linux or Windows) the Docker CLI talks to. Select Switch to Windows containers to use Windows containers, or select Switch to Linux containers to use Linux containers (the default).