Concepts / Container networking

Container networking

Network namespace

Also called netns, ip netns, container network, network stack

A separate copy of the kernel's network: its own cards, addresses, routes and firewall, which is what a container's network is.

One kernel, separate networks
One kernel, separate networks

Each namespace has its own cards, addresses, routes, ARP cache and firewall rules, and sees nothing of the others. A veth pair is the virtual cable that joins two of them.

A network namespace is a separate copy of the Linux network stack: its own cards, addresses, route table, ARP cache and iptables rules, starting with only lo. Programs inside see no other network. A container's network is one; Docker makes one per container. ip netns add web makes a named one, ip netns exec web <command> runs a command inside it, and ip -n web addr reads it from outside.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab