What are Docker networking modes?
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.