Technical Mid Level

How does Docker networking work? Explain bridge, host, and overlay networks, and how containers communicate with each other and the outside world.

Quick Tip

Clarify the key difference: "Custom bridge networks give automatic DNS — containers find each other by name. The default bridge does not. I always create a named network in Compose rather than relying on the default."

What good answers include

Bridge (default): creates a private network on the host. Containers on the same bridge can communicate by container name (DNS resolution via embedded DNS server). Exposed ports are mapped to the host with -p. Host: container shares the host network namespace directly — no isolation but no port mapping overhead. Overlay: spans multiple Docker hosts for Swarm or multi-node setups. Containers communicate via virtual networks. Key concepts: each bridge gets a subnet, containers get IP addresses, port publishing (host:container mapping), and custom bridge networks provide automatic DNS resolution (the default bridge does not). Strong candidates discuss: using custom networks for service isolation, the difference between expose and publish, container-to-container communication within Compose, and DNS-based service discovery.

What interviewers are looking for

Tests understanding of container networking. Candidates who only use port mapping without understanding bridge networks will struggle with multi-container setups. Those who understand DNS resolution and network isolation can design proper service architectures.

← All Docker questions