CONTAINERS / A CONCEPT NOTE

Container Networking

how containers find each other

~65 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

Containers use virtual network interfaces (veth pairs) linked to a virtual bridge (docker0). The bridge routes packets locally, while iptables rules translate port bindings for external traffic.

02 / FOLLOW THE MECHANISM

How packet passing flows

  1. Creation

    container runtime creates a veth pair, placing one end inside the container namespace.

  2. Bridge Link

    places the other end of the pair on the host's virtual bridge (e.g. docker0).

  3. IP allocation

    assigns a private IP address (like 172.17.0.2) to the container interface.

  4. Port Forwarding

    iptables translates traffic landing on host port 80 to container IP port 8080.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

list all local container networks

docker network ls

EXAMPLE 02 · REFERENCE

inspect IP allocations and bridge configuration

docker network inspect bridge

Explore command anatomy in the CLI lab