Skip to content
Blog

The Docker Host Network Driver Means Zero Isolation

What --network host really gives a container: the host's interfaces, ports, and localhost, no namespace separation. Platform support, the discarded -p flag, and when to say no.

Published on • November 19, 2026

AI Assistant

Add --network host and Docker stops creating a network namespace for the container. No veth pair, no bridge, no NAT, no separate IP — the process joins the host’s network stack directly. That single sentence contains both the appeal (native speed, zero plumbing) and the danger (the container can see and touch everything the host can). The host driver isn’t “bridge but faster.” It’s no boundary at all, and the details worth knowing are all consequences of that.

What actually changes

For comparison, here’s what a container gets by default versus in host mode:

--network bridge (default):
  container netns → veth → bridge → iptables NAT → host NIC
  own IP, own ports, isolated loopback

--network host:
  container process → host netns → host NIC (and 127.0.0.1)
  host IP, host ports, shared loopback

Concretely, in host mode the container:

  • Sees every host interface and address. ip addr inside the container lists the real eth0, lo, and any VLANs — not a virtual eth0@ifN.
  • Binds host ports directly. A service listening on port 80 inside the container is listening on the host’s port 80. No -p, no DNAT, no docker-proxy.
  • Shares the host’s localhost. 127.0.0.1:6379 inside the container is the host’s Redis. A container that can reach host-local services can reach every unauthenticated one.
  • Collides with host services. Two containers can both bind port 80 on a bridge network. In host mode the second one dies with bind: address already in use — as would any process competing for the port.
  • Loses per-container firewall identity. The filter/DNAT rules Docker writes for bridge containers simply don’t apply; the process is subject to the host’s own rules and routing.

The mode is also transparent about port flags — try to publish a port and Docker tells you exactly what you’d expect:

docker run -d --name web-host --network host -p 8080:80 nginx:alpine
WARNING: Published ports are discarded when using host network mode

Not an error — a design statement. There is nothing to publish to; the container already owns the host’s port space.

Platform support: Linux native, Desktop opt-in

Host mode behaves very differently depending on where you run it:

EnvironmentSupportNotes
Linux (native Engine)FullContainer shares the real host network stack — the original and complete implementation
Docker Desktop 4.34+ (macOS/Windows)Opt-inEnable in Settings → Resources → Network → Enable host networking
Docker Desktop before 4.34Not available--network host targets the VM, not your OS

On Docker Desktop (4.34 and later), even with the setting enabled, the documented limitations are important: you can’t bind to specific host IPs (layer-4 reachability only), the mode is layer-4 only — no layer-7 host integration — it’s incompatible with Enhanced Container Isolation, and it supports Linux containers only. And historically, --network host on Desktop meant “the Linux utility VM’s network,” so a service bound to port 80 inside was not reachable at localhost:80 on your Mac or Windows. The opt-in feature exists precisely because that behavior confused everyone.

Rule of thumb: on a Linux server, host mode does what the name says. On Desktop, read the current docs for your version before designing around it.

The security case against casual use

Host mode removes an isolation boundary, and it’s worth being specific about what a compromised container gains:

  1. Full localhost reach. Host daemons bound to 127.0.0.1 (Redis, databases, agent sockets, the Docker API on some setups) become reachable with no extra flags. On a bridge network, they aren’t.
  2. Traffic visibility. With CAP_NET_RAW (or broader caps), the container can sniff the host’s interfaces — every packet, every other tenant’s traffic.
  3. Port squatting. Anything the container binds occupies the host’s port space, including ports your monitoring or orchestration expects to control.
  4. No egress asymmetry. Bridge containers get Docker-managed firewall rules; a host-networked process is just another host process, with whatever exposure that implies.

None of this makes host mode wrong — it makes it a deliberate trade, not a performance shortcut you reach for by default.

When it’s the right tool

Host mode earns its place in three scenarios: network-sensitive agents (Prometheus node_exporter, tcpdump/capture tools, anything that must see real host interfaces); ultra-low-latency or high-port-count services (real-time media, trading systems, apps needing hundreds of dynamic UDP ports where -p lists become absurd); and localhost-bound integrations where fighting host.docker.internal is more complexity than the boundary is worth. For everything else — web apps, APIs, databases, Compose stacks — a user-defined bridge gives you name resolution, per-container isolation, and explicit, auditable port mappings.

services:
  node-exporter:
    image: prom/node-exporter:latest
    network_mode: "host"
    pid: "host"

Note the pairing: host network plus host PID is a monitoring pattern, and a reminder that these flags tend to travel together — each one you add widens the blast radius.

Bridge or host? A quick decision table

QuestionBridge (user-defined)Host
Does the service need its own port space?Yes — five containers can share port 80No — one owner per host port
Must it be isolated from host 127.0.0.1 services?Yes, by defaultNo — it shares them
Does it need container-name DNS?Yes, via embedded DNSNo — it uses the host’s resolver and hosts file
Is it latency- or interface-sensitive (capture, exporters)?NoYes
Do you need -p to control exposure?Yes, explicit and auditableImpossible — flags are discarded

When the left column describes your workload, --network host buys nothing and costs a boundary. When the right column does, the bridge is the thing getting in the way.

The bottom line

The host network driver gives the container the host’s interfaces, port space, and localhost, and discards port publishing in the process. That’s zero isolation — a performance and simplicity win for agents and latency-critical services on Linux, and a security decision that should be argued for, not defaulted into. Ask what boundary you’re deleting before you type --network host, because the container inherits everything on the other side of it.

Further reading