0

I have a Docker overlay network which includes 2 containers and the loadbalancer for this network:

    "Containers": {
        "0ece6b958aa6b451478b5004ba1b1681ec91b718b99a0c2c88b79d5e8e135a66": {
            "Name": "flvw_nginx.1.v9ycohipbvizlagm840o7jd0d",
            "EndpointID": "0fba09c56d5098efb3a89645a5dce575a12b5f3496d3839ce4e34bb29bc60091",
            "MacAddress": "02:42:0a:00:16:06",
            "IPv4Address": "10.0.22.6/24",
            "IPv6Address": ""
        },
        "25b2988afe5d0cf02f718831bf12858b3dccb875a3609804273da02bd4b422ac": {
            "Name": "flvw_pimcore.1.j3m0i52sksg0fmhdawzhwwhei",
            "EndpointID": "a2ea9ddcfba20b05017dda7a79af542ab09b0172a74f61be9fbb861fad39d008",
            "MacAddress": "02:42:0a:00:16:03",
            "IPv4Address": "10.0.22.3/24",
            "IPv6Address": ""
        },
        "lb-flvw_app": {
            "Name": "flvw_app-endpoint",
            "EndpointID": "c4cf9798cd3d2d8ee11057176c9f7395fd81546860f97c2623cd7f5043104294",
            "MacAddress": "02:42:0a:00:16:04",
            "IPv4Address": "10.0.22.4/24",
            "IPv6Address": ""
        }
    },

This states:

pimcore = 10.0.22.3
nginx = 10.0.22.6

So I exec into the containers and the following commands.

On the pimcore container:

[root@25b2988afe5d pimcore]# ip a | grep -i "10.0.22"
    inet 10.0.22.3/24 brd 10.0.22.255 scope global eth0

[root@25b2988afe5d pimcore]# ping nginx
PING nginx (10.0.22.5) 56(84) bytes of data.
64 bytes from 10.0.22.5 (10.0.22.5): icmp_seq=1 ttl=64 time=0.062 ms
64 bytes from 10.0.22.5 (10.0.22.5): icmp_seq=2 ttl=64 time=0.052 ms
^C

On the nginx container:

[root@0ece6b958aa6 /]# ip a | grep -i "10.0.22"
    inet 10.0.22.6/24 brd 10.0.22.255 scope global eth0
[root@0ece6b958aa6 /]# ping pimcore
PING pimcore (10.0.22.2) 56(84) bytes of data.
64 bytes from 10.0.22.2 (10.0.22.2): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from 10.0.22.2 (10.0.22.2): icmp_seq=2 ttl=64 time=0.065 ms

Result:

Pimcore says its own IP is 10.0.22.3 (which corresponds to the network inspect output) and that nginx' IP is 10.0.22.5 (which does not correspond).

Nginx says its own IP is 10.0.22.6 (which corresponds to network inspect) and that pimcore's IP is 10.0.22.2 (which does not correspond).

Containers seem to see other containers "1 number off", in a way of speaking. Why?

My TCP/IP knowledge is definitely not high level, but this feels weird. Maybe someone can englighten me!

1

When you ping nginx the docker swarm returns Virual IP of swarm service named "nginx" not the container ip.

This is is how internal load balancer works - you can have multiple replicas of "nginx" containers behind the "nginx" service. enter image description here

| improve this answer | |
  • 1
    I see. That makes sense. I figured "I only have one instance, so why would there be something in front of it?". But it makes sense that there is always a load balancer in front as you might scale in the future and then it's already there. Thanks for the insight! – Worp Oct 2 '19 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.