Container Networking
Cheat sheet · https://pcornel.dk/topic.php?topic=6076
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 codesdocker logs <c>— container outputdocker 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
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | Bridge networking | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Host networking / Port publishing and NAT | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Overlay networking | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | macvlan/ipvlan concepts | The original bounded check succeeds in the same time window | Production 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