7.2.1.3 Bridge Name Resolution
A focused guide to Bridge Name Resolution, connecting core concepts with practical Docker and container operations.
Bridge name resolution is the automatic DNS-based lookup Docker provides for containers attached to a shared, user-defined bridge network, allowing each container to resolve other containers' names directly to their current IP addresses on that network.
How Resolution Works in Practice
Each user-defined bridge network runs an embedded DNS server, automatically resolving container names (and any configured network aliases) for containers attached to that specific network.
docker network create app-network
docker run -d --name cache --network app-network redis:7
docker run -d --name api --network app-network myapi:1.0
docker exec api getent hosts cache
This resolves cache to its current IP address on app-network, handled automatically without any manual configuration.
Resolution Is Scoped to a Specific Network
A container's name is only resolvable by other containers sharing the same network — a container on a different network has no automatic way to resolve that name, even if both containers exist on the same host.
docker network create network-a
docker network create network-b
docker run -d --name service-a --network network-a alpine sleep 1000
docker run -d --name service-b --network network-b alpine sleep 1000
docker exec service-b ping service-a
This fails, since service-a and service-b are on entirely separate networks, each with its own independent resolution scope.
Connecting a Container to Multiple Networks for Cross-Network Resolution
A container attached to multiple networks can resolve names from each network it's connected to, providing a way to bridge resolution across what would otherwise be separate, isolated networks.
docker network connect network-a service-b
docker exec service-b ping service-a
Why Bridge Name Resolution Matters
Automatic, network-scoped name resolution is the key practical advantage user-defined bridge networks provide over the default bridge, making container-to-container communication in a multi-container application both convenient and resilient to changes in a container's underlying IP address.