What Is a Privileged Container? Kubernetes Permissions and Safer Alternatives
A privileged container in Kubernetes receives much broader operating-system permissions than an ordinary container. On Linux, setting `securityContext.privileged: true` grants every Linux capability and can disable or bypass kernel protections such as seccomp, AppArmor, and SELinux. Consider it only when host-level work is essential, such as for a node-management agent; ordinary applications should receive only the specific permissions they need.
What Is a Privileged Container? Kubernetes Permissions and Safer Alternatives
A privileged container in Kubernetes receives much broader operating-system permissions than an ordinary container. On Linux, setting securityContext.privileged: true grants every Linux capability and can disable or bypass kernel protections such as seccomp, AppArmor, and SELinux. Consider it only when host-level work is essential, such as for a node-management agent; ordinary applications should receive only the specific permissions they need.
This article covers Linux containers on Kubernetes. Windows hostProcess containers have a related host-permission model but use different settings and constraints. Confirm behavior against your distribution, runtime, and Kubernetes version.
What changes when privileged: true is set?
A container is not a virtual machine with its own kernel. Linux containers share the host kernel, while namespaces, capabilities, seccomp, AppArmor, and SELinux limit process access. Privileged mode relaxes several of these layers: Kubernetes documents that a privileged container receives all Linux capabilities, runs with seccomp Unconfined, ignores an applied AppArmor profile, and uses the SELinux unconfined_t domain. A process running as root inside it can therefore gain access to node-level networking or kernel-management operations.
This setting does not automatically join the host PID, network, or IPC namespace, nor does it expose every host file. hostPID, hostNetwork, hostIPC, and hostPath are separate settings. Combining them with privileged mode can widen the impact because other protective boundaries are already weaker. Privileged mode is also different from running as UID 0: runAsUser and runAsNonRoot select the process identity, while privileged changes the permission boundary. A non-root UID alone does not make a privileged container narrowly authorized.
How is this different from adding a capability?
Linux capabilities split traditional all-or-nothing administrative power into narrower permissions. If an application needs one network-management operation, identify and grant only the required capability when possible. Privileged mode includes all capabilities and affects other protections, so it is not a sensible first response to a single “permission denied” error.
allowPrivilegeEscalation: false is not a replacement for privileged mode. It limits a process from gaining additional permissions at runtime; it does not restore kernel restrictions that privileged mode has removed. Evaluate each control separately and enforce policy separately.
Diagnose an application's permission request
Suppose a log collector asks for privileged mode because it cannot read host network information. First identify the denied system call, file, or device and compare it with the operating-system and runtime requirements. Check whether application configuration or file ownership can remove the need. If access remains necessary, consider a single capability, a specific device, or a narrowly scoped read-only mount. Review host namespace or filesystem sharing as separate decisions.
The following is a starting point for a typical Linux application, not a ready-to-deploy manifest. Verify the real image's UID, file permissions, writable paths, and runtime behavior first.
apiVersion: v1
kind: Pod
metadata:
name: app
spec:
containers:
- name: app
image: example.invalid/app:1.0 # placeholder; replace with a real image
securityContext:
privileged: false
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefaultThe example will not fit every application. The image must support non-root execution; add a suitable volume only for paths that need writes. Removing all capabilities can break some applications. If that happens, inspect logs and the denied operation, identify the cause, and add only the narrow permission needed. Test in a non-production environment instead of enabling privileged mode to make the error disappear.
Prevent mistakes with cluster policy
The Pod Security Standards Baseline level is a starting point for ordinary workloads and disallows privileged containers. Restricted adds stricter requirements, including non-root execution, no privilege escalation, and capability limits, so test compatibility before enforcing it. The Privileged policy level means that the policy imposes few restrictions; it does not automatically make every Pod in that namespace privileged.
Pod Security Admission can apply the selected level at Pod creation based on namespace configuration. A safer rollout is to first use warn or audit to find existing violations, review impact and exceptions, then enforce the policy in suitable namespaces. Behavior can depend on cluster version and pinned policy version. Keep necessary exceptions, such as node agents, in a dedicated namespace with restricted create/update permissions, node placement constraints, narrow network access, a named owner, and a review date.
Verify and recover
Before deployment, review the actual Pod template, including init and ephemeral containers, for privileged mode, added capabilities, host namespace sharing, hostPath, and service-account permissions. If admission rejects a Pod, use the error to find the offending field and separate the application's functional requirement from the manifest setting. Check whether image users, file permissions, or application behavior can be fixed. Reproduce changes in staging, run functional and permission checks, then deploy. If the workload still fails, roll back to the last verified version and record any policy exception with its scope, expiry, and owner.
The key question is not only “does the app run as root?” Ask which host resources and kernel functions it truly needs, whether a smaller permission can provide them, and who will review and revoke any exception. Most applications do not need privileged mode.
Sources
[Kubernetes: Linux kernel security constraints and privileged containers](https://kubernetes.io/docs/concepts/security/linux-kernel-security-constraints/)
[Kubernetes: Pod Security Standards](https://kubernetes.io/docs/concepts/security/pod-security-standards/)
[Kubernetes: Pod Security Admission](https://kubernetes.io/docs/concepts/security/pod-security-admission/)
[Kubernetes: Application Security Checklist](https://kubernetes.io/docs/concepts/security/application-security-checklist/)