Rootless Containers: Host Privileges, User Namespaces, and Kubernetes
Rootless execution runs the container engine or runtime without host root privileges and maps container identities through a user namespace. Learn how this differs from running an app as non-root, what security it adds, and what Kubernetes support requires.
Rootless Containers: Host Privileges, User Namespaces, and Kubernetes
A rootless container setup runs the container engine or runtime without the host's actual root privileges, and maps the container through a user namespace so it runs as an unprivileged host user. A process that appears as root inside a container can therefore map to a restricted UID on the host. This reduces potential host impact if an engine or container is compromised, but it is not the same as merely running the application as a non-root user, and it does not solve every security problem.
How is this different from a non-root container process?
runAsNonRoot or runAsUser in Kubernetes controls the UID of the application process inside the container. Rootless mode changes the privilege boundary of the engine/daemon and container execution path on the host. A non-root application can still be created and managed by a rootful runtime.
Docker's userns-remap and rootless mode also differ. With userns-remap, container UID/GID values are mapped to other host IDs but the daemon still runs as host root. In Docker rootless mode, both daemon and containers run without host root privileges. A remapped container UID alone does not prove the engine is rootless.
What does a user namespace change?
A Linux user namespace separates the user and group IDs and some capabilities visible inside a namespace from host identities. A process can appear as UID 0 inside a container while mapping to an ordinary user or subordinate UID/GID range on the host. Capabilities granted inside a user namespace do not automatically become host privileges outside it.
Requirements are product- and platform-specific. Docker's documented rootless prerequisites include newuidmap, newgidmap, and subordinate ID ranges in /etc/subuid and /etc/subgid. Filesystem ownership, volumes, networking, privileged ports, devices, and cgroup delegation can also behave differently. Do not assume every rootful feature works unchanged.
Which Kubernetes settings are related?
| Setting | Privilege boundary changed | Meaning |
|---|---|---|
securityContext.runAsNonRoot / runAsUser | Application UID inside container | Prevents or selects the app's in-container user; does not make the node runtime rootless |
Pod user namespace (hostUsers: false) | Mapping from Pod IDs to host IDs | A process that is root in the Pod can map to an unprivileged host ID |
| Rootless node/engine operation | Host privileges of kubelet, runtime, or engine | Runs node components as non-root; requires separate platform support |
Kubernetes Pod user namespaces have been stable since v1.36. The current Kubernetes documentation describes this as Linux-only and requiring idmapped-mount support for node and Pod-volume filesystems, plus a compatible CRI and OCI runtime. The docs say Linux 6.3 is typically needed for those mounts. hostUsers: false is not the same as runAsNonRoot; it also cannot be combined with host namespace sharing such as hostNetwork, hostPID, or hostIPC. Check the target cluster's Kubernetes, kernel, runtime, filesystem, and provider support before using it.
When should you consider rootless execution?
It can help on multi-user development hosts or other environments where the engine does not need host-root privileges. Workloads that need special devices, host networking, particular file ownership, or cgroup controls may require extra configuration or may not be supported. Validate the needed features in the target runtime and platform and plan a recovery path.
Rootless execution mainly reduces privilege available after compromise. It does not remove vulnerable images or applications, unsafe network exposure, plaintext credentials, or runtime vulnerabilities. Protect engine sockets and user accounts, patch components, and maintain least privilege, network policy, secrets controls, and monitoring.
A practical evaluation sequence is: identify which boundary you want to lower; check the official requirements for the OS, kernel, engine/runtime, Kubernetes and CRI versions; plan tests for volumes, networking, ports, devices, resource controls and observability; validate in a non-production environment; then document rollback and ownership. Do not assume an untested cluster works.
Sources
[Docker: Rootless mode](https://docs.docker.com/engine/security/rootless/)
[containerd: Running containerd as a non-root user](https://containerd.io/docs/main/rootless/)
[Kubernetes: User Namespaces](https://kubernetes.io/docs/concepts/workloads/pods/user-namespaces/)
[Kubernetes: Configure a Security Context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
[Kubernetes: Running node components as a non-root user](https://kubernetes.io/docs/tasks/administer-cluster/kubelet-in-userns/)