How does `--network host` work and what are the trade-offs?
IntermediateConceptNetworking
Answer
The container shares the host's network namespace: no veth, no NAT, no port mapping (-p is ignored). Lowest latency and handy for performance or tools needing host interfaces. Costs: port conflicts, no network isolation, and on Docker Desktop it applies to the VM (recent versions added opt-in host networking support). Not usable with Compose service name DNS across networks.
More on Networking
What network drivers does Docker have?BeginnerHow does the default bridge network work?AdvancedDefault bridge vs user-defined bridge: what is the difference?IntermediateHow does container DNS work?IntermediateHow does `-p 8080:80` work under the hood?AdvancedWhat is the difference between `-p 80:80` and `-p 127.0.0.1:80:80`?Beginner