Skip to content

Hardening a container: user, read-only root, capabilities

Select an icon to see what it is.

Step 5 of 6

no-new-privileges blocks escalation

--security-opt no-new-privileges makes runc set a flag on the process. With it, running a setuid program, or one with file capabilities, does not give the process extra privileges. The kernel shows the flag as NoNewPrivs 1.

$ docker run -d --name hardened --security-opt no-new-privileges alpine sleep 1000

grep NoNewPrivs /proc/1/status inside the container

NoNewPrivs: 1