no-host-namespaces
pid: host, ipc: host, uts: host, cgroup: host and userns_mode: host share the host's namespaces with a Compose service. What each one exposes and what to set instead.
On this page
Linux gives each container its own view of process IDs, shared memory, the hostname, control groups and user IDs. Compose lets a service drop any of these views and use the host's instead, with pid: host, ipc: host, uts: host, cgroup: host or userns_mode: host. It usually enters a file to make one tool work, such as a profiler that needs to see host processes or a training job that ran out of shared memory, and then stays. This rule reports each of those keys when it is set to host, one finding per key.
pid: hostlets the container see and signal every process on the host.ipc: hostshares the host's shared memory and message queues with the container.uts: hostshares the host's hostname and domain name.cgroup: hostshows the container the host's whole cgroup tree instead of its own.userns_mode: hostturns off user namespace remapping for the container, so root in the container is root on the host.
pid: service:db and ipc: service:db share a namespace with another service, not with the host, and the rule does not report them. network_mode: host is not reported here because it is common and often correct.
What the rule catches
services:
agent:
image: my-agent:1.2.0
pid: host
ipc: hostScanning this file reports:
⚠ WARN [docker-doctor/no-host-namespaces]
Service 'agent' sets 'pid: host', so the container can see and signal every process on the host.Why it matters
Namespaces are what make a container's view of the machine smaller than the machine. A service that shares the host's PID namespace can inspect every process and its open files and signal them. One that shares the IPC namespace can read the shared memory of host processes. These settings also decide how far a container escape bug goes. In November 2025 runc fixed three escapes, CVE-2025-31133, CVE-2025-52565 and CVE-2025-52881. The advisories for the first two strongly recommend user namespaces, with the host's root user not mapped into the container, because that blocks most of the serious parts of the attacks. userns_mode: host opts a service out of that protection.
How to fix it
Remove the key so the service gets its own namespace. If ipc: host is there for shared memory, as PyTorch and vLLM often need, set shm_size instead.
services:
inference:
image: my-inference:1.2.0
shm_size: 2gb
pid: service:gateway
gateway:
image: my-gateway:1.2.0Remove the key unless the service cannot work without it:
- Shared memory for PyTorch, vLLM and similar tools: set
shm_sizeon the service. This is the usual reasonipc: hostis added, and a sized/dev/shmdoes the same job without sharing the host's IPC. - A profiler or debugger that must see another process: share the namespace with that one service using
pid: service:name, or run the tool on the host. - Rootless or remapped containers: leave
userns_modeunset so the daemon's remapping applies.
Host monitoring agents, such as a node exporter that reads host process data, legitimately set pid: host. Set this rule to off in docker-doctor.config.json for a project that exists to run such a tool.
Rule details
- Rule key —
docker-doctor/no-host-namespaces - Category — Compose
- Default severity —
warning - Applies to — Docker Compose files
Explain this rule from the CLI:
npx @docker-doctor/cli@latest rules explain docker-doctor/no-host-namespacesChange its severity — or turn it off — in your config file:
// docker-doctor.config.ts
export default {
rules: {
"docker-doctor/no-host-namespaces": "off",
},
};Severity affects the health score: error findings cost more points than warning, and info costs the least.