The purpose of this work is to investigate how overlay network works under the hood.
Before we start, create a swarm cluster as it is described in Swarm Tutorial or take this Vagrant file and setup your box with guest additions.
Create an overlay network and a service
ip netns looks for network namespaces in /var/run/netns, but Docker keeps them in different place and does not create symlink. Let’s create it by hands:
d7b2c48c9596 is a network namespace of a container running on this node:
1-d4j6wl1h53 is actually a namespace for overlay network created by swarm init, 1-qhmpedvga9 is our created network named mynet:
It’s time to look inside overlay network namespace:
veth0 is a peer interface of eth0 inside container
vxlan0 is a virtual network interface for containers inter-node communication
br0 is a bridge connecting all vethN and vxlan0 together
02:42:c0:a8:37:04 is a container 2ccc289ad154 running on manager node and container ip address is 192.168.55.4.
02:42:c0:a8:37:03 is a container 6de050036519 running on worker node, container ip is 192.168.55.3.
Now it’s clear to us that the communication between nodes works over VXLAN driver.
But how Docker’s VXLAN is juggling on L2 level, how MAC addresses are being populated between nodes?
Start arping from first container and inspect network traffic in second one, observe there are no any arp requests received on remote container side:
In case both containers running inside the same node, we can sniff all arp broadcast from all this node containers:
ARP, FDB tables.
Containers from the same node communicate via br0, and MAC address learning works via broadcasts.
For containers running on different nodes the information is dynamically populated by Docker, see the permanent flag:
Since Docker manages fdb/arp entries on vxlan0, arp-learning is disabled and vxlan0 acts as arp-proxy (see the proxy flag):