Checks / Docker and containers

A container shares the host PID namespace

Check
docker.host_pid
Severity
medium
Runs
on the server, in the daily run of the agent
Looks at
PidMode is host
Updated 26 Nov 2026

What the check looks at

HostConfig.PidMode of every running container (docker inspect). The check fails for each container where it is host. The setting comes from --pid=host on docker run or from pid: host in a Compose file.

Risk

With --pid=host the container shares the process list of the host. In a test on Docker 29.9:

  • the container saw all processes of the host, and /proc/1/comm was systemd;
  • it could read their command lines, as ps -ef shows them, with any tokens or passwords given as arguments;
  • kill -0 1 succeeded from a root process in the container, on a host without an AppArmor profile for containers, so the container could send signals to host processes and stop them;
  • reading /proc/1/environ was denied, because the container lacks CAP_SYS_PTRACE.

SYS_PTRACE or --privileged removes that limit: capabilities(7) describes CAP_SYS_PTRACE as the right to "trace arbitrary processes using ptrace(2)".

How to fix it

  1. Check why the container has it. Monitoring agents that report on host processes and some debugging tools need it; applications and databases do not.
  2. Remove pid: host from the Compose file, or --pid=host from the docker run command.
  3. Recreate the container: docker compose up -d --force-recreate <service>.

If two containers need to see the processes of one another (a sidecar that debugs an application), share the namespace of that one container with --pid=container:<name>, and not the one of the host.

How to check the fix

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

The output must be empty.

When a warning is fine

A monitoring agent that reports per-process figures of the host needs it, and so does a container you start for a debugging session. If the image comes from a source you trust and runs without extra capabilities, accept the result for that container on the dashboard. Add --privileged or SYS_PTRACE only if the tool needs that too.

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

Sources