LOGBOOK

HELP

Quiz Entry - updated: 2026.11.10

What does the host network driver do, and what do you observe when nginx runs with --network host?

The container shares the host's network stack directly: no own IP, no veth, no NAT and no port mapping. nginx itself binds port 80 on the host, while storage, processes and users stay isolated.

With docker container run -d --network host --name hostnginx nginx, the container skips its own network namespace. The application behaves network-wise as if it were started on the host:

  • http://localhost (port 80) shows the nginx page without any -p; publishing ports has no effect in host mode.
  • ip addr show shows no new veth interface, only the docker0 bridge that always exists.
  • sudo ss -ltnp 'sport = :80' shows the nginx process itself listening on 0.0.0.0:80 (for a bridge container with -p you'd see Docker's port-forwarding instead).
  • The port must be free: the lab first stops the host's own Apache (sudo systemctl disable --now apache2), otherwise nginx could not bind 80.

Trade-off: host mode is faster (no NAT, no bridge) and handy for tools that must see the host's real interfaces. But it gives up network isolation: the container can bind any host port and reach services listening only on the host's localhost. The other isolation (filesystem, PID and user namespaces) still applies.

Host network mode: nginx in the container binds port 80 directly in the host's network stack, without veth, NAT or port mapping

* The container shares the host's network stack; other namespaces stay separate. *

Go deeper:

From Quiz: ISLAB / Docker Introduction | Updated: Nov 10, 2026