Chapter 17Lesson 01~110 minutes

Container Networking Foundations: Bridge, Host, None, User-Defined Networks, Endpoints, and Namespaces: Concepts, Architecture, and Mental Model

Understand Docker networking as network namespaces, endpoints, virtual interfaces, bridge drivers, routes, DNS, and host firewall policy rather than as automatic connectivity.

Docker networkingNetwork namespacesBridgeEndpointsEvidence

Learning objectives

  • Explain the path from a container network namespace through an endpoint/veth pair and Docker bridge/driver to host routing/firewall policy and peers.
  • Distinguish Docker network objects, container endpoint attachments, container-visible interfaces/routes/DNS, and host-level bridge/firewall implementation.
  • Compare the default bridge, user-defined bridge, host, and none drivers without confusing them with port publishing.
  • Use read-only inspection to prove network IDs, drivers, addresses, gateways, endpoint attachments, DNS settings, and platform/firewall assumptions.
  • Explain why stable service discovery and explicit network membership are safer than hard-coded container IP addresses.
Chapter 17 principle. Connectivity is never “because Docker.” A packet leaves a process through a container-visible interface, follows a route in that network namespace, crosses an endpoint and driver-managed path, then encounters host routing/firewall policy before it reaches a peer or external network. Diagnose that chain in order.

1. Why container networking needs its own mental model

Earlier chapters separated client, daemon, image, container, and process state. Networking adds another set of objects that can fail independently. A container can be running and healthy while attached to the wrong network. Two containers can be on the same Docker host but intentionally isolated. A published port can exist while the application is not listening. Conversely, two containers on the same user-defined bridge can communicate directly without any published host port.

The practical goal is to stop treating a failed request as one vague “Docker network problem.” Instead, identify which layer owns the failure: application listener, container network namespace, endpoint attachment, Docker network driver, DNS, host routing/firewall, or an external path.

2. Mental model: from process socket to peer

A normal bridge-networked container has its own network namespace. Inside it, the application sees an interface such as eth0, an IP address, a route, and DNS configuration. Docker creates an endpoint that connects this namespace to the selected Docker network. On Linux bridge networks, that endpoint is commonly implemented through a virtual Ethernet path into a host-side software bridge. Host routing, NAT/masquerading, and firewall rules then govern traffic leaving that network or entering through published paths.

Container-to-peer packet path
flowchart TD
  P[Application process socket bind/connect] --> N[Container network namespace eth0 + IP + routes + DNS]
  N --> E[Docker endpoint virtual interface attachment]
  E --> D[Network driver user-defined bridge]
  D --> H[Host routing + firewall iptables by default / nftables optional]
  H --> C[Peer endpoint on same network]
  H --> X[External network via host routing/NAT]
            

Do not read the diagram as a promise that every platform exposes identical host interfaces. Docker Desktop runs Linux containers behind a managed VM boundary, so the same logical network object can be implemented differently from a native Linux Engine host. The Docker API and container-visible state remain the portable evidence layer.

3. Four different things called “the network”

Layer What it is Evidence Why it matters
Docker network object Daemon-managed object with name, ID, driver, IPAM, options, labels, and connected endpoints. docker network inspect Defines intended membership and driver behavior.
Container endpoint/sandbox The container attachment to one Docker network; a multi-homed container has multiple endpoints. docker inspect → NetworkSettings.Networks Proves which networks actually attach to the container.
Container-visible stack Interfaces, IPs, routes, DNS resolver, loopback, listening sockets. docker exec ... ip addr, ip route, /etc/resolv.conf Shows what the workload can actually use.
Host implementation Bridge devices, forwarding, NAT/filter rules, firewall backend, Desktop VM path. Read-only host tools where authorized; Docker docs/version evidence. Explains traffic beyond the namespace without making container internals the whole story.

4. Bridge, host, and none are different isolation contracts

Mode Network namespace behavior Addressing / DNS Important consequence
Default bridge Container gets an isolated stack attached to Docker's built-in bridge. IP connectivity exists; automatic container-name DNS is not the recommended discovery path on this legacy network. Useful for simple cases, but unrelated containers can accumulate on one shared default network.
User-defined bridge Container gets an isolated stack attached to a project-specific bridge. Automatic name/alias resolution through Docker embedded DNS; configurable IPAM/options. Preferred same-host application boundary; dynamic connect/disconnect is supported.
host Container does not get a separate network stack from the host. No separate container IP; host ports/interfaces are the relevant stack. Port publishing is ignored; portability and isolation are reduced.
none Container gets an isolated stack with only loopback. No normal external interface/default route. Useful when the workload should have no network connectivity.

Docker documents host networking for Linux Engine and, as an opt-in feature, Docker Desktop 4.34+. Desktop host networking is layer-4 only and has additional restrictions. Treat host mode as platform-sensitive, not as a portable shortcut.

5. DNS differs between default and custom networks

Containers attached to the default bridge receive resolver configuration based on the host. Containers attached to a custom network use Docker's embedded DNS service, currently exposed inside the container at 127.0.0.11. The embedded resolver supports name/alias lookup for peers on the same user-defined network and forwards external lookups to configured host DNS.

This is why service name is normally a better identity than container IP. Endpoint addresses can change after recreation; a name on the intended network expresses the relationship rather than an incidental allocation.

6. Read-only inspection before changing anything

docker version
docker info
docker context show

docker network ls
docker network inspect bridge
docker network inspect host
docker network inspect none

# Existing containers only; no state change:
docker ps -a --no-trunc
docker inspect <container> --format '{{json .NetworkSettings.Networks}}'
docker port <container>

On an authorized native Linux host, additional read-only evidence may include ip link, ip route, and firewall-rule inspection. Do not edit Docker-managed firewall rules as a troubleshooting shortcut. On Docker Desktop, treat VM-internal host networking as an implementation boundary rather than assuming the Windows/macOS host directly owns Linux bridge devices.

7. Firewall backend is host policy, not container application state

Docker Engine creates firewall rules for bridge networking. The current default backend is iptables. Engine 29 introduced an experimental nftables backend selectable by daemon configuration; Docker explicitly warns that behavior can change and that overlay-network migration is not complete. That makes backend choice a version-sensitive host assumption.

For this chapter, the safe approach is read-only: record Engine version and any available firewall-backend evidence, then diagnose container and Docker network state first. Chapter 19 will treat port publication and firewall/NAT behavior in depth.

8. Evidence inventory for a reproducible network state

Evidence Example Question answered
Network identity name + ID + driver + labels Which exact Docker network object are we discussing?
Endpoint identity container ID + network name + endpoint ID Is this container actually attached?
Addressing IP/MAC + gateway + subnet What addresses/routes should exist?
Container routes ip route Where will packets be sent?
DNS /etc/resolv.conf + successful name lookup Which resolver/discovery mechanism is active?
Application listener process/logs or local loopback request Is the application accepting traffic before we blame Docker networking?
Host/platform Engine/Desktop version + OS/context + firewall assumption Which implementation/caveats apply?

9. Misconceptions to retire

  • “localhost means the Docker host.” In a bridge-networked container, localhost refers to that container's own network namespace.
  • “same host means containers can talk.” User-defined networks intentionally scope membership and isolation.
  • “EXPOSE opens a port.” It does not publish anything; publication is a separate host-exposure decision.
  • “container IP is stable service identity.” It is an allocation, not a durable contract.
  • “host mode is faster, so use it everywhere.” It trades away isolation/port-mapping semantics and is platform-sensitive.
Next lesson

Next: Guided Hands-On Workflow and Core Operations

Build a disposable same-host lab, prove user-defined bridge DNS and isolation, inspect endpoint/routes, add and remove a second network, and compare bridge, none, and optional host mode without touching daemon policy.

Knowledge check

A container is running but cannot reach another container by localhost. What is the first conceptual correction?

Why are user-defined bridges preferred over the legacy default bridge for application peers?

What happens to -p when a container uses host networking?

What network interfaces exist with the none driver?

Why should iptables versus nftables be treated as host/version evidence rather than application configuration?

Official references and version notes

Version baseline checked 2026-09-21.

Docker Engine 29.8.1 is the current Engine release baseline used for version-sensitive discussion. Docker Engine on Linux uses iptables by default for bridge-network firewall rules; the nftables backend introduced in Engine 29 remains experimental. Docker Desktop host networking is supported from Desktop 4.34+ as an opt-in feature and operates at layer 4. Always record the installed Engine/Desktop version and actual network/firewall state before drawing conclusions.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.