Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 74 of 8021. Container FundamentalsFree lesson

Configuring Docker Default Bridge Networking

Examine how the docker0 bridge acts as a virtual switch to facilitate communication between containers residing on the same host machine.

In this lesson, you will learn how the docker0 bridge functions as a virtual switch to connect containers running on your host machine.

The Virtual Switch Concept

When you install Docker, it creates a virtual network interface called docker0. Think of docker0 as a physical network switch sitting inside your computer. When you launch a container without specifying a custom network, Docker automatically attaches that container to this bridge.

Each container is given its own virtual network namespace. To get traffic out of that isolated namespace and onto the network, Docker creates a "Virtual Ethernet" (veth) pair. One end of the pair stays inside the container (usually mapped to eth0), and the other end plugs directly into the docker0 bridge.

How Containers Talk to Each Other

Because every container on the default bridge is plugged into the same "virtual switch," they are all on the same Layer 2 network segment. If Container A wants to talk to Container B, the traffic follows this path:

  1. Container A sends a packet to its local eth0.
  2. The packet travels across the veth pair to the docker0 bridge.
  3. The bridge inspects the destination IP address and determines which veth port leads to Container B.
  4. The packet is forwarded to Container B’s eth0.

You can verify this bridge exists on your host by running:

ip addr show docker0

This bridge is what allows your containers to communicate with each other using their internal private IP addresses without needing to pass through your host's physical network interface. It essentially creates a private, isolated ecosystem where your containers can interact as if they were physically cabled into the same office switch, even though they are just processes running in isolated namespaces on your machine.

Key Takeaway: The docker0 bridge acts as a virtual switch, using veth pairs to interconnect containers so they can communicate seamlessly within the same host.