Docker bridge networking explained
Lab prerequisites
Use an approved, disposable Linux Docker Engine VM with no external network access, ordinary bridge/NAT settings, and Engine 28.0.0 or later for publication labs. Verify the local context, server version, and that all bm-v05 names used in this example are unused. Use a reviewed, preloaded busybox:1.37 image; record its digest and check that httpd, wget and nslookup are present where used. The tag is not immutable. Run commands individually, stop on unexpected failure, and clean up only resources you created. Results below are expected, not observed. Before contacting the Engine, verify the effective local endpoint including DOCKER_HOST, DOCKER_CONTEXT and CLI overrides. Recheck the approved local image ID and native platform; if the recorded digest is unavailable, report it as unknown rather than inventing one. Use owner-set resource and time limits. If prerequisites cannot be confirmed, do the paper exercise instead. The VM must have no other untrusted workloads, no external routes and no direct-routing exceptions. A loopback mapping or internal bridge alone does not provide these guarantees. Use only a patched, supported Engine release meeting the stated minimum.
A small virtual network
A bridge acts like a virtual network switch on one Engine host. With normal Linux bridge networking, each container has its own network interfaces and addresses. 127.0.0.1 in a container refers to that container, not another container or the host. A packet to a peer on the same bridge does not need a host port mapping. The default bridge is created by the Engine; user-defined bridges allow clearer grouping and built-in name resolution. Do not assume a bridge spans hosts. This example assumes ordinary bridge networking and a listener reachable through the container interface; it does not describe host networking or sharing another container’s network namespace.
Read the network inventory
These commands are read-only. Use them only in your approved VM and avoid sharing private topology or full inspection output.
docker network lsdocker network inspect --format '{{.Driver}}' bridgeOn a normal Linux Engine, the network named bridge uses driver bridge. IDs and the other networks vary. If the default network is unavailable, skip the default-bridge example rather than modifying daemon settings.
Inspect one container network
Start a short-lived fixture on the default bridge and inspect only its network names. The VM must be disconnected from external networks because default bridge networking can permit outbound traffic. If the 120-second sleep has already ended, skip stop and remove only the verified exited fixture.
docker run -d --pull=never --network bridge --name bm-v05-bridge busybox:1.37 sleep 120docker inspect --format '{{range $name, $net := .NetworkSettings.Networks}}{{$name}}{{end}}' bm-v05-bridgedocker stop bm-v05-bridgedocker rm bm-v05-bridgeExpected network name: bridge. The fixture does not publish a port. Its IP address is intentionally not asserted.
Manual practice
Sketch two containers on one bridge and label each separate loopback interface. Explain why localhost in container A does not point to container B.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Docker bridge networking explained — Knowledge check
Apply the concepts from this lesson.
In ordinary bridge networking, what does localhost inside container A identify?
Do peers on a shared bridge need host port publication to communicate?
What is the scope of an ordinary bridge network?