Docker Community Forums

Share and learn in the Docker community.

Accessing containers inside an overlay network from the host machine is unstable


(Dennis W) #1

I’ve set up a Docker Swarm Cluster v1.11.2 to which I deploy services via docker-compose. I’ve created an external overlay network and defined it as default network for each service in the docker-compose.yml files.

version: "2"
        image: my.reg:5000/service1:latest
        - "10080:10080"
        - .
        - "affinity:container!=service1*" 

            name: myoverlay

I’m using my own Consul cluster outside of the Docker world for service registration, with one Consul agent running natively on each swarm node. What’s obviously necessary is that the Docker containers advertise themselves with their overlay address in Consul, so that they would be able to find each other that way.

As each container receives one address out of the overlay network for eth0 and one address from the local docker bridge subnet on eth1, I decided to have all the containers connect to the Consul server processes via, as the native Consul processes listen on

So: registration always to, advertising as some address from

The registration works fine, access from the containers to the outside world is not an issue. I put a static route on each swarm node telling it

route add -net netmask gw

But the connections through this route are unstable. Sometimes it’s possible to ping a container within the overlay network from the host machine, then all of a sudden the connection can’t be established anymore. What I get then is

dennis@testing-01:~$ ping
PING ( 56(84) bytes of data.
From icmp_seq=1 Destination Host Unreachable
dennis@testing-01:~$ ifconfig 
docker0   Link encap:Ethernet  HWaddr 02:42:18:4d:3f:56  
      inet addr:  Bcast:  Mask:
      inet6 addr: fe80::42:18ff:fe4d:3f56/64 Scope:Link
      RX packets:5673 errors:0 dropped:0 overruns:0 frame:0
      TX packets:5179 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:897736 (897.7 KB)  TX bytes:4439952 (4.4 MB)

docker_gwbridge Link encap:Ethernet  HWaddr 02:42:28:14:0e:12  
      inet addr:  Bcast:  Mask:
      inet6 addr: fe80::42:28ff:fe14:e12/64 Scope:Link
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:185952 errors:0 dropped:0 overruns:0 frame:0
      TX packets:269592 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:21059294 (21.0 MB)  TX bytes:30183068 (30.1 MB)

I don’t really get why this is such a big issue. Can anyone point me in the right direction?

(Gsc30190) #2

I want communication between docker container on overlay and a VM. How can I achieve this? Any solution.