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

HostConfig.NetworkMode of every running container (docker inspect). The check warns for each container where it is host. The setting comes from --network=host (or --net=host) on docker run, or from network_mode: host in a Compose file.

Risk

With the host network, a container uses the network stack of the host in place of its own interfaces, 127.0.0.1 and ports. In a test on Docker 29.9, such a container saw 23 interfaces instead of 2, and 7 TCP sockets of the host on 127.0.0.1. Many services treat loopback as a boundary: admin interfaces, metrics endpoints, databases, the Docker API if someone set it to tcp://127.0.0.1. A process in the container reaches all of them, and with CAP_NET_ADMIN it can change the interfaces and firewall rules of the host.

The ports of such a container are ordinary sockets of the host, so ufw and firewalld filter them, unlike ports published with -p. For that reason the severity is low.

How to fix it

  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 a 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 as well as 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'

The output must be empty.

When a warning is fine

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

An accepted result stays out of the digest and the counts until it changes.

Sources