Linux capabilities and no-new-privileges
Linux capabilities divide many traditional root privileges into separate privileges. Docker can reduce the capabilities available to container processes. The no-new-privileges setting additionally prevents gaining new privileges through program execution mechanisms such as set-user-ID binaries; it does not remove existing privileges.
Worked example
This is an offline lesson. Scenarios are fictional and Docker commands are unexecuted. Any optional execution requires an approved disposable VM, a reviewed preloaded image with verified digest, blocked external access and appropriate resource limits. No host-policy change, real credentials or live scan is required. Keep the exercise offline. Before any separately authorized runtime check, verify the effective daemon, builder, runner or deployment identity as applicable; use synthetic data, reviewed inputs and bounded resources. Record missing evidence as NOT RUN.
docker run --rm --pull=never --network none \ --user 10001:10001 --cap-drop ALL \ --security-opt no-new-privileges=true \ busybox:1.36 echo bytemind-okThis is a staged command, not observed output. It assumes a preloaded reviewed BusyBox Linux image, a compatible Engine, and authorized disposable context. The simple echo operation should not require special capabilities. The numeric user avoids relying on the image default; --cap-drop ALL removes the configured capability grants, while no-new-privileges restricts acquiring new ones. These options work alongside the normal seccomp policy and other enforced host controls. For a service with legitimate special requirements, establish the exact need and review a minimal exception rather than granting broad privileges. Verify both application behavior and effective process security state in the target environment. Do not disable protections to make a test pass. Expected echo output is a positive control only. In an authorized lab record the actual UID/GID, effective capability state and no-new-privileges state, and distinguish them from requested flags. The example is not a full workload security policy and does not include explicit resource limits.
Common mistake
No-new-privileges does not replace capability reduction, and nonroot alone does not establish the entire privilege boundary.
Manual practice
Review a fictional text formatter that requests extra capabilities. Explain why none should be granted without a demonstrated requirement; propose an output test and a control verification.
Worksheet: lab-fixtures/docker-container-security/05-capabilities/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Linux capabilities and no-new-privileges — Knowledge check
Apply defensive container security reasoning in a fictional scenario.
What does no-new-privileges prevent?
Why start with no capabilities for the toy echo task?
A hardened application fails to start. What is the next step?