Pcornel
Containers

Container Networking

Cheat sheet · https://pcornel.dk/topic.php?topic=6076

Back to the Topic

Answer

Container networking connects containers to each other and the outside: Docker bridge networks with NAT and port publishing, host networking, and in Kubernetes a flat pod network provided by a CNI plugin plus Services for stable access.

Remember

Test from inside the container. Containers reach each other by name only on user-defined networks (Docker) or via Service DNS (Kubernetes). Apps must listen on 0.0.0.0, not 127.0.0.1.

First checks

  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Verify in this order

container netns → veth → bridge/CNI → routing/NAT → service/ports

Where it usually breaks

Typical failures include an application bound only to loopback, wrong published port, missing return path, overlapping subnets, DNS/service-name confusion, MTU problems on overlays and policy/NAT rules that differ between host and namespace.

Container Networking verification boundary matrix

BoundaryInspectHealthy interpretationDo not infer
IntentBridge networkingIntended object/scope is explicit and versioned where relevantIntent is already effective
Owning runtime/control planeHost networking / Port publishing and NATOwner accepts and reports the expected object stateDownstream dependencies are healthy
Effective stateOverlay networkingIndependent read-back matches the intended stateEvery client sees the same result
Consumer outcomemacvlan/ipvlan conceptsThe original bounded check succeeds in the same time windowProduction correctness outside this scope

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6076

Confirmation

Confirm action

Continue?