Checks / Docker and containers

A container uses the host network

Check
docker.host_network
Severity
low
Runs
on the server, in the daily run of the agent
Looks at
NetworkMode is host
Updated 26 Nov 2026

What the check looks at

The agent reads HostConfig.NetworkMode of every running container from docker inspect and reports each container where it is host. The setting comes from --network=host (or --net=host) on docker run, or network_mode: host in a compose file.

Why it matters

A container on a bridge network has its own network stack: its own interfaces, its own 127.0.0.1, its own ports. With the host network it uses the stack of the host. In a test on Docker 29.9, a container on the host network saw 23 interfaces instead of 2, and 7 TCP sockets of the host that listen on 127.0.0.1.

That matters because many services count on loopback as a boundary: admin interfaces, metrics endpoints, databases bound to 127.0.0.1, the Docker API if someone set it to tcp://127.0.0.1. A process in a host-network container reaches all of them. With CAP_NET_ADMIN added, it can also change the interfaces and firewall rules of the host.

There is an upside. Ports of such a container are ordinary sockets of the host, so ufw and firewalld filter them, which is not the case for ports published with -p. That is why the severity is low.

How to fix it

The commands are the same on every distribution.

  1. Check whether the software needs the host network. Some VPN servers, network monitoring tools and programs that use multicast or broadcast on the LAN (service discovery, some media servers) do. A web application or database does not.

  2. Remove network_mode: host and publish the ports the container serves, bound to loopback if only the host needs them:

    services:
      app:
        image: example/app:1.4.2
        ports:
          - "127.0.0.1:8080:8080"
    
  3. If the container needs a service of the host, point it at the host from the bridge network. With extra_hosts: ["host.docker.internal:host-gateway"] the name host.docker.internal resolves to the address of the host on the default Docker bridge (172.17.0.1 on a default setup, the address of docker0). The service on the host must then listen on that address, not only on 127.0.0.1.

  4. Recreate the container: docker compose up -d --force-recreate <service>.

How to check the fix

docker ps -q | xargs -r docker inspect --format '{{.Name}} net={{.HostConfig.NetworkMode}}' | grep 'net=host'

No output means no running container uses the host network.

When a warning is fine

Software that has to see or configure the network of the host, such as a VPN gateway, a network monitor or a DHCP server, needs it. Check that the services the host keeps on 127.0.0.1 are ones that container may reach, then accept the result for that container on the dashboard.

An accepted result is left out of the digest and the counts until it changes; then it shows again.

Sources