Skip to content

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

Select an icon to see what it is.

Step 4 of 6

--cap-drop ALL removes capabilities

Linux splits root's powers into capabilities, such as changing file owners or loading kernel modules. --cap-drop ALL puts CapDrop in the request and runc empties the container's capability sets. You can add one back with --cap-add, only if the program needs it.

$ docker run -d --name hardened --user 1000:1000 --cap-drop ALL alpine sleep 1000

grep Cap /proc/1/status inside the container

CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000000000000000
CapAmb: 0000000000000000