Root in a container: which powers remain?
Capabilities, no_new_privs and ordinary writable files
UID, capabilities, no_new_privs and read-only filesystems protect different boundaries. Ordinary writable data remains writable.
An HTTP API normally needs to receive requests and talk to a database. It generally does not need to manage network interfaces, load kernel modules or mount filesystems.
Linux capabilities divide many traditional root privileges into separate powers. They are associated with threads, not a universal “administrator mode.”
UID is only one part of the story
| Capability | Example of its power | |---|---| | CAPCHOWN | Changing file ownership beyond ordinary permissions | | CAPDACOVERRIDE | Bypassing ordinary file permission checks, subject to kernel details | | CAPNET_ADMIN | Certain network administration operations |
UID 0 in a container can therefore be more constrained than root on a typical host. User and network namespaces, seccomp and SELinux or other security modules also affect what succeeds. A capability does not bypass every other control.
Docker supplies a reduced default set. Reduce it further based on the service's actual needs. Using --privileged to fix an unexplained permission error expands much more than the one permission you failed to understand.
Four settings answer four questions
This is a container securityContext fragment, not a complete deployment:
These controls compose. None is a synonym for all the others.
Observe the boundary locally
Run a disposable workload with a deliberately writable temporary directory and without capabilities. Ordinary file creation there can still succeed. Compare that with a privileged operation the process no longer has permission to perform.
Use a suitable local image and non-root identity; do not grant privileged mode just to make an experiment pass. A permission failure is evidence to investigate, not a request for every power.
The important limitation
A compromised service can still read secrets and modify data it legitimately accesses. Removing CAPDACOVERRIDE does not remove ordinary write permission to a customer's files.
Narrow the exposed volumes and secrets, filesystem ownership, mount permissions and network access alongside the process identity and capabilities. Test which directories the application genuinely needs for caches, uploads and temporary files.
Check yourself
A non-root process has no capabilities but a read-write mount containing customer files. Do these settings prevent it from modifying those files? No. No special capability is required for a write already allowed by ordinary permissions.
The goal is a small, understood set of powers. A container boundary alone does not describe it.