Summary
A service needed a real LAN IP (bypassing Docker bridge's default NAT) so internal IoT devices could reach it directly, so bridge, overlay, macvlan, and host networking modes were surveyed to find the right fit.
System Context
- •Docker Engine 26.x on Ubuntu 22.04, single host (no Swarm/K8s yet)
- •Internal LAN: 192.168.1.0/24, with its own DHCP range for macvlan
- •Compared 4 modes: bridge, overlay, macvlan, host
Checklist
- ☑Macvlan container receives a real LAN IP, reachable by ping from another device
- ☑Compared throughput: host network vs bridge network (iperf3)
- ☑Overlay network works correctly between 2 Docker hosts via Swarm
- ☑Confirmed host mode doesn't conflict with other services' ports on the machine
Commands
Step 1
docker network create --driver bridge app-netStep 2
docker network create -d overlay --attachable mesh-netStep 3
docker run --network host nginxStep 4
docker network inspect app-netConclusion
Bridge networks suffice for single-host development. Overlay networks are essential for Swarm multi-host communication. Macvlan is useful when containers need direct LAN IP addresses. Host networking eliminates NAT overhead for high-performance workloads.