Isolate container users from the host with Linux user namespaces
Answer: Linux namespaces isolate running processes and limit their access to system resources. A user namespace can map a container user to a less-privileged user on the host.
Docker userns-remap
Docker remaps that user to a less-privileged user on the Docker host. Inside the namespace, those mapped UIDs still act as the normal 0-to-65536 range, yet they have no privileges on the host machine itself. If privilege escalation is attempted outside the namespace, that process runs as an unprivileged high-number UID on the host. With userns-remap, the Docker daemon still runs as root.
Kubernetes pods
Kubernetes shows how to configure a user namespace for pods. The container user is isolated from the host user. Root inside the container can correspond to a different, non-root user on the host. Skip the user namespace, and a root container can keep root privileges on the node after a breakout.
| namespace | user | |---|---| | Linux namespaces | Isolation for running processes, limiting access to system resources | | user namespace | Maps a container user, including root, to a host user | | userns-remap | Docker setting that remaps container UIDs | | UID range | Mapped UIDs that function as 0 to 65536 inside the namespace | | pods | Kubernetes can configure a user namespace for pods |
See
Claims
- id: C1 claim: Linux namespaces provide isolation for running processes. source: S1 evidence: "Linux namespaces provide isolation for running processes"
- id: C2 claim: Docker can remap a container user to a less-privileged user on the host. source: S1 evidence: "re-map this user to a less-privileged user on the Docker host"
- id: C3 claim: A Kubernetes pod user namespace isolates the container user from the host user. source: S2 evidence: "isolate the user running inside the container from the one in the host"
Sources
- [S1] Isolate containers with a user namespace. Docker docs. https://docs.docker.com/engine/security/userns-remap/ . License: Apache-2.0. Accessed 2026-11-19.
- [S2] Use a User Namespace With a Pod. Kubernetes docs. https://kubernetes.io/docs/tasks/configure-pod-container/user-namespaces/ . License: CC-BY-4.0. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, Isolate containers with a user namespace; Kubernetes docs, Use a User Namespace With a Pod. Apache-2.0; CC-BY-4.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs, Isolate containers with a user namespace; Kubernetes docs, Use a User Namespace With a Pod. Apache-2.0; CC-BY-4.0.
Cite this
iinventedlight. 2026. "Isolate container users from the host with Linux user namespaces." iinventedlight Library, iil:note:hh6tz99f, version of 2026-11-19. https://iinventedlight.com/library/notes/linux-user-namespaces/. License: CC-BY-4.0.
@misc{iil_note_hh6tz99f,
author = {{iinventedlight}},
title = {{Isolate container users from the host with Linux user namespaces}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/linux-user-namespaces/},
note = {Permanent ID iil:note:hh6tz99f. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- linux-user-namespaces.table.json (table; CC-BY-4.0)
- linux-user-namespaces.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/linux-user-namespaces.md.