Bridge Networks
What you'll learn: How Docker's default bridge network connects containers on a single host and why custom bridges provide better isolation and naming.
The Default Bridge Network
When Docker starts, it creates a default bridge network called bridge. Think of it like a virtual Ethernet switch inside your host machine—containers plugged into it can talk to each other using IP addresses, but they're isolated from the host's main network unless you explicitly expose ports.
Every container you launch without specifying a network automatically joins this default bridge. However, containers here can only communicate by IP address, not by container name (no automatic DNS resolution).
Custom Bridge Networks
You can create custom bridge networks to organize containers logically. Unlike the default bridge, custom bridges provide:
- Automatic DNS resolution: containers discover each other by name
- Better isolation: only containers on the same custom bridge can communicate
- On-the-fly attachment: connect/disconnect containers without restarting them
Custom bridges are like creating separate virtual switches for different application stacks (e.g., one bridge for your web tier, another for backend services).
Container-to-Container Communication
Within a bridge network, containers share a private subnet. They can reach each other directly using either IP addresses or—on custom bridges—container names. The bridge driver handles routing packets between containers automatically.
When you need external access, you publish container ports to the host, effectively creating a "gateway" through the bridge.
Key Takeaway:
Bridge networks connect containers on the same host; the default bridge uses IPs only, while custom bridges add DNS-based discovery and better isolation for organized, name-based communication.