Skip to content

Bridges and veth pairs: how containers share a network

Select an icon to see what it is.

Step 6 of 6

The bridge's table, and docker0

The bridge keeps a forwarding table of MAC addresses and ports, which bridge fdb shows. Docker's default bridge, docker0 at 172.17.0.1/16, works the same way. The difference is DNS: names resolve only on user-defined networks like shop-net.

$ bridge fdb show
PrevNext

bridge fdb show (excerpt)

02:42:ac:12:00:02 dev veth<web> master br-<network id>
02:42:ac:12:00:03 dev veth<api> master br-<network id>

Try it yourself

Create the network and inspect the bridge and veth ends on the host.

$ docker network create --subnet 172.18.0.0/16 shop-net
$ docker run -d --name web --network shop-net nginx
$ ip -br addr show type bridge
$ bridge link show
$ docker exec web ip addr show eth0
$ docker rm -f web
$ docker network rm shop-net

Quiz

1. What is a veth pair?
2. How does the bridge know where to send a frame?
3. Why does the TTL not change between web and api?