🐳 Docker Beginner

What are Docker networking modes?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Docker topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

Docker provides several networking modes that control how containers communicate: (1) bridge (default for standalone containers): Docker creates a virtual bridge network. Each container gets an IP on this private network; they communicate via IPs or container names (with DNS on user-defined networks). The host connects via port mapping (-p 8080:3000). Use user-defined bridge networks instead of the default bridge — they provide automatic DNS resolution by container name; (2) host: the container shares the host's network namespace — no isolation. Container binds directly to host ports (no port mapping). Best performance, worst isolation. Linux only (not available on Mac/Windows Docker Desktop); (3) none: no network — completely isolated. Useful for containers that don't need network access (batch processing); (4) overlay: for Docker Swarm — spans multiple Docker hosts, enabling containers on different machines to communicate as if on the same network; (5) macvlan: assigns a real MAC address to the container, making it appear as a physical device on the network. Useful for legacy applications expecting direct network access. Commands: docker network create mynet, docker network ls, docker network connect mynet container.

Pro Tip

If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.