Use this when limiting root powers inside containers.
Linux Capabilities · Container Security
Linux capabilities split root's powers into units like NET_ADMIN or SYS_ADMIN. Containers should drop all capabilities and add back only what they need, and never run privileged.
1. Drop all capabilities and add only needed ones.
2. Avoid CAP_SYS_ADMIN, NET_ADMIN, SYS_PTRACE.
3. No privileged containers.
4. allowPrivilegeEscalation: false.
5. Enforced by restricted PSA.
container → capability set → kernel operations
Context & applicabilityCommon mistakes · platform/version boundaries
- Running with Docker's default capability set when far fewer are needed.
--cap-add=ALLorprivileged: trueto fix permission errors.- Forgetting
allowPrivilegeEscalation: falseandno-new-privileges. - Assuming non-root user means no capabilities — file capabilities on binaries can still grant them.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Capabilities split root into units like NET_ADMIN.
- Drop ALL and add back only what is needed.
- Never run --privileged in production.
docker inspect <c> --format '{{.HostConfig.CapAdd}} {{.HostConfig.CapDrop}}'— capabilitieskubectl get pod <p> -o jsonpath='{..securityContext.capabilities}'— pod capscapsh --decode=<hex>— decode CapEff
ReferenceWhy it matters1 section · depth on demand
Dropping capabilities
docker run --cap-drop ALL --cap-add NET_BIND_SERVICE nginx
Kubernetes:
securityContext:
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"]
allowPrivilegeEscalation: false
Documented example, not captured output. Never run --privileged or add SYS_ADMIN without a strong reason; together with host mounts they allow container escape.
ReferenceHow it works1 section · depth on demand
In depth
Linux capabilities in containers determine which root-like privileges a container process has. Container runtimes drop many capabilities by default but still grant some (e.g. CHOWN, NET_BIND_SERVICE, SETUID); the safest approach is to drop all and add back only what is needed.
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"]
docker run --cap-drop ALL --cap-add NET_BIND_SERVICE nginx
Never grant SYS_ADMIN, NET_ADMIN or SYS_PTRACE without a strong reason — and avoid privileged: true, which grants all capabilities and device access, effectively removing container isolation. The Kubernetes "restricted" Pod Security Standard enforces these rules.
ReferenceConfiguration & state1 section · depth on demand
Commands
docker run --cap-drop=ALL --cap-add=NET_BIND_SERVICE nginx
# Kubernetes
securityContext:
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"]
Documented example, not captured output. Check a running process with grep Cap /proc/<pid>/status and decode with capsh --decode=<hex>. Never add SYS_ADMIN unless there is no other way — it is close to root.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Container Security → Linux Capabilities. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/sp/800/190/final · confidence 94%