When would you use `--network host`?
IntermediateScenarioNetworking and Compose
Answer
Situation read → Needs maximum network performance or many dynamic ports.
What I'd do → Use it for packet capture tools, node-level monitoring agents or high-throughput proxies on Linux. Do not combine with -p; those flags are ignored.
Why → Skips NAT and veth overhead, but port conflicts with the host are possible and the container sees all host interfaces.
Interview tip → It does not work the same on Docker Desktop (VM boundary).
More on Networking and Compose
Containers on the default bridge cannot resolve each other by name. Why, and what do you do?BeginnerHow do you expose a container only to the local host, not the internet?BeginnerDesign a Compose file for web + api + postgres + redis with correct startup ordering.IntermediateFrontend must reach the API but not the database. Segment the network.IntermediateA container needs to call a service running on the Docker host.BeginnerTwo Compose projects need to talk to each other.Intermediate