Container & Kubernetes Networking Fundamentals
Understand Docker bridge and host networks, veth pairs, iptables packet forwarding, Kubernetes CNI plugins, and Service Mesh.
1. Docker Network Drivers
| Driver | Description | Use Case |
|---|---|---|
bridge (Default) | Creates a private virtual software bridge (docker0). Containers get private IPs (172.17.0.x) and communicate via port mapping (-p 3000:3000). | Standalone multi-container apps on single host |
host | Bypasses network isolation; container shares host machine's network stack directly. | Maximum network throughput ($>10\text{Gbps}$), low latency |
overlay | Multi-host distributed network connecting Docker Swarm nodes across different physical machines. | Multi-host container clustering |
none | Disables all external networking (loopback interface only). | Isolated batch computation / security sandboxes |
2. How Docker Bridge Networking Works
[ Container 1 (172.17.0.2) ] [ Container 2 (172.17.0.3) ]
│ (eth0) │ (eth0)
▼ ▼
(veth_abc123) (veth_def456)
└──────────────────┬──────────────────┘
▼
[ docker0 Linux Bridge ]
│ (NAT / iptables forwarding)
▼
[ Host Physical NIC (eth0) ]Each container connects to the docker0 software bridge via a Virtual Ethernet Pair (veth). Outbound internet traffic from containers is translated using Linux kernel iptables NAT (Masquerading).
3. Kubernetes Networking Model & CNI
In Kubernetes:
- Every Pod gets its own unique IP address.
- Pods can communicate with all other Pods across nodes without NAT.
- Networking is implemented by a Container Network Interface (CNI) plugin (e.g. Cilium with eBPF, Calico, Flannel, AWS VPC CNI).
4. Service Mesh Introduction (Istio / Linkerd)
A Service Mesh injects a lightweight sidecar proxy (Envoy) next to every application container to provide:
- Mutual TLS (mTLS): Automatic end-to-end encryption between microservices.
- Observability: Distributed tracing and latency metrics.
- Traffic Shifting: Canary deployments (e.g. route 5% of traffic to v2).
Production Load Balancing & High Availability Strategies
Architect high availability load balancers, Anycast BGP routing, connection draining, and zero-downtime blue-green deployments.
Introduction to Git Version Control
Understanding Git: distributed version control vs centralized systems, snapshots vs deltas, and the three-tree architecture.