December 1, 2026
Docker container networking diagram

Docker networking modes control how containers communicate with each other and the host. This guide explains bridge, host, overlay, and none modes with practical examples and when to use each.

Why Docker networking matters

By default, Docker containers are isolated. They cannot talk to each other or to the host unless you explicitly configure networking. Choosing the wrong mode leaves your application unreachable or exposes it to security risks.

Docker networking modes

Mode Description Best for
bridge Default mode. Containers on the same bridge can communicate; host access requires port mapping. Standalone containers, development
host Container shares the host’s network namespace. No port mapping needed. High-performance networking, legacy apps
overlay Multi-host networking across Docker Swarm nodes. Swarm services, multi-node clusters
none No network interface. Container is isolated. Security-sensitive batch jobs

Bridge mode (default)

Bridge is the default. Each container gets an internal IP address on a private bridge network. Containers on the same bridge can reach each other by IP. To reach the host or outside world, you must map container ports to host ports:

docker run -d -p 8080:80 nginx

This maps host port 8080 to container port 80. Without the -p flag, the container is unreachable from outside.

Create a custom bridge for better isolation:

docker network create myapp-network
docker run -d --network myapp-network --name web nginx
docker run -d --network myapp-network --name app myapp-image

Containers on the same custom bridge can reach each other by container name, which Docker resolves through embedded DNS.

Host mode

Host mode removes network isolation. The container uses the host’s IP address and ports directly. No port mapping is needed:

docker run -d --network host nginx

If the container listens on port 80, it is reachable on the host’s port 80 immediately.

Security warning

Host mode gives the container full access to the host’s network interfaces. A compromised container can scan and attack services running on the host. Do not use host mode for untrusted workloads.

Overlay mode

Overlay mode is for Docker Swarm. It creates a distributed network across multiple Swarm nodes, so containers on different physical hosts can communicate as if they are on the same network:

docker network create -d overlay swarm-network
docker service create --network swarm-network --name web nginx

Overlay requires Docker Swarm mode and uses VXLAN encapsulation. It adds encryption and key rotation automatically.

None mode

None mode disables all networking. The container has only a loopback interface:

docker run -d --network none batch-job-image

Use this for jobs that process local files and should never send or receive network traffic.

Choosing the right mode

Scenario Recommended mode Why
Web application with database Custom bridge Isolation plus name-based service discovery
Legacy app expecting host ports host No port mapping changes needed
Multi-node Swarm cluster overlay Cross-node container communication
One-off batch job none Maximum network isolation

Useful DevStackIO Tools

Quickly test your Docker network configurations with our free tools:

Related Reading

Frequently Asked Questions

Can containers on different bridge networks communicate?
Not directly. Connect one container to both networks with docker network connect, or use a container with multiple network interfaces as a gateway.
How do I expose a container port on a specific host IP only?
Use docker run -p 192.168.1.100:8080:80 to bind to a specific host interface instead of 0.0.0.0.
What is the performance difference between bridge and host mode?
Host mode has lower latency and higher throughput (no NAT/bridge overhead). On Linux, the difference is typically 5-15% for high-throughput workloads. On Docker Desktop (macOS/Windows), host mode is not available.
Can I use overlay networking without Swarm?
No. Overlay networks require Docker Swarm mode. For multi-host networking without Swarm, use a CNI plugin (Calico, Weave, Flannel) with Kubernetes or a custom solution.
How do I debug container connectivity issues?
Use docker exec -it container-name nslookup other-container to test DNS, docker network inspect to verify network membership, and tcpdump on the host bridge interface to trace packets.

Leave a Reply

Your email address will not be published. Required fields are marked *