Default Bridge vs User-Defined Bridge Networks
Prefer user-defined bridges for DNS-based service discovery between containers.
In plain words
Create a user-defined bridge for each application boundary so services use stable names and remain isolated from unrelated containers.
Think of it like…
The default bridge is a shared lobby with seat numbers; a user-defined bridge is a meeting room with a nameplate directory.
Where you’ve seen it
In practice, docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db is the concrete move for this job: prefer user-defined bridges for DNS-based service discovery between containers. The release is not accepted until disconnect db from shop and observe DNS/connection failure without changing the database IP configuration confirms the result.
Words you’ll hear
- Default Bridge
- The implementation control in
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup dbfor prefer user-defined bridges for DNS-based service discovery between containers. - User-Defined
- The result to observe with
disconnect db from shop and observe DNS/connection failure without changing the database IP configuration, rather than infer from a successful command alone. - DNS
- The production boundary exposed when using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge.
Visual diagram
Theory & deep dive
Default Bridge control path
The concrete mechanism is docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db. The observable result is disconnect db from shop and observe DNS/connection failure without changing the database IP configuration; if those disagree, inspect the runtime evidence before changing unrelated settings.
Prefer user-defined bridges for DNS-based service discovery between containers. Keep Default Bridge, User-Defined and DNS in the same deployment record so the intent and the observed state cannot drift apart.
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db
disconnect db from shop and observe DNS/connection failure without changing the database IP configuration, not with command success alone.DNS failure boundary
Relying on IP addresses breaks as containers are recreated. On a custom bridge a container name or network alias can resolve, but DNS works only for peers attached to the same network-not through the Docker default bridge. The narrow failure to design for is using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge.
Accept this compromise explicitly: User-defined bridges improve DNS and isolation; each additional network requires explicit attachment and dependency reasoning. The controlled check-disconnect db from shop and observe DNS/connection failure without changing the database IP configuration-also identifies the point where a different design is safer.
Exercise this failure safely: using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: Relying on IP addresses breaks as containers are recreated. On a custom bridge a container name or network alias can resolve, but DNS works only for peers attached to the same network-not through the Docker default bridge.
- Intent
- Default Bridge
When to use it & trade-offs
What it is
The legacy docker0 bridge gives containers egress and supports published ports but requires legacy links or IPs for many peer-discovery workflows. A user-defined bridge provides embedded DNS, automatic per-container DNS updates and explicit membership.
Why it matters: Relying on IP addresses breaks as containers are recreated. On a custom bridge a container name or network alias can resolve, but DNS works only for peers attached to the same network-not through the Docker default bridge.
When to reach for it
- The fit is strongest for this job: prefer user-defined bridges for DNS-based service discovery between containers. Pair it with
disconnect db from shop and observe DNS/connection failure without changing the database IP configurationin the runbook. - Production Default Bridge changes should make User-Defined observable through
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db, rather than trusting the runtime default. - Keep a rollback example for the case where using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge.
When to avoid or be careful
- Do not accept command success while the system can still fail by using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge.
- Avoid erasing DNS protection merely to dodge this cost: “User-defined bridges improve DNS and isolation; each additional network requires explicit attachment and dependency reasoning”.
- Do not replace the evidence path-
disconnect db from shop and observe DNS/connection failure without changing the database IP configuration-with a screenshot or a mutable tag.
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db: practical choices
Strengths: The legacy docker0 bridge gives containers egress and supports published ports but requires legacy links or IPs for many peer-discovery workflows. A user-defined bridge provides embedded DNS, automatic per-container DNS updates and explicit membership.
Watch out: User-defined bridges improve DNS and isolation; each additional network requires explicit attachment and dependency reasoning.
Strengths: It can begin with docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db and fewer surrounding controls.
Watch out: It silently accepts using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge, which makes the result hard to reproduce after promotion.
Strengths: Relying on IP addresses breaks as containers are recreated. On a custom bridge a container name or network alias can resolve, but DNS works only for peers attached to the same network-not through the Docker default bridge.
Watch out: The platform adds an ownership and debugging layer; retain disconnect db from shop and observe DNS/connection failure without changing the database IP configuration as the direct check.
Interview signals & numbers to know
When this topic comes up
- docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db
- disconnect db from shop and observe DNS/connection failure without changing the database IP configuration
- Failure signature: using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge
- Trade-off: User-defined bridges improve DNS and isolation; each additional network requires explicit attachment and dependency reasoning.
Benchmarks & rules of thumb
- 127.0.0.11
- Docker embedded DNS address inside a user-defined network
- 1 Docker host
- scope of a bridge network
- 0 stable IP guarantees
- for ordinary recreated containers
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup dbas proof and skippingdisconnect db from shop and observe DNS/connection failure without changing the database IP configuration. - Using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge
- Optimizing Default Bridge without accepting that user-defined bridges improve DNS and isolation; each additional network requires explicit attachment and dependency reasoning.
Likely interviewer follow-ups
- Why does
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup dbaddress Default Bridge here rather than through application code? - How would you distinguish healthy User-Defined from the failure “using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge” using
disconnect db from shop and observe DNS/connection failure without changing the database IP configuration? - When would this trade-off-“User-defined bridges improve DNS and isolation; each additional network requires explicit attachment and dependency reasoning”-justify a different DNS design?
docker network create shop; docker run -d --name db --network shop postgres:17; docker run --rm --network shop alpine:3.21 nslookup db-and one proof-disconnect db from shop and observe DNS/connection failure without changing the database IP configuration. Then name the boundary: using --link as a modern service-discovery strategy, or resolving a service that is attached to a different user-defined bridge.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Default Bridge vs User-Defined Bridge Networks with generative AI interview Q&A and hands-on practice.