What is a bridge network?
bridge is a virtual network that Docker creates on the host to connect containers with each other. It works like an internal router: each container gets its own private IP, and Docker automatically sets up routes and a built-in DNS.
How bridge works:
- when a container starts, Docker connects it to the
bridgenetwork and assigns it an IP (for example,172.17.0.2); - containers in this network can reach each other by IP or by container/service name;
- access to the outside world goes through NAT on the host;
- from the outside, the container is unreachable until ports are published.
When bridge is used:
- for local development;
- for small projects on a single host;
- for scenarios where services need to see each other but stay hidden from the outside network.
Example:
bash
docker run -d --name app nginx
docker run -d --name db mysqlBoth containers end up in the bridge network and can communicate, for example: mysql://db:3306.
Key features of bridge:
| Property | Description |
|---|---|
| Isolated from the host | Containers are in their own private network |
| Has DNS | Containers see each other by name |
| NAT outward | Containers have internet access |
| Ports required for inbound access | -p 8080:80 |
Summary: bridge is a local private Docker network for containers on a single host to interact, isolated from the outside network with a convenient internal DNS.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.