-
Notifications
You must be signed in to change notification settings - Fork 416
Improve docker container security
mviereck edited this page Oct 15, 2018
·
5 revisions
-
Avoid root in container. Create an unprivileged user in container, e.g. with
--user 1000:1000or with a custom/etc/passwdfile. - Drop all capabilities with
--cap-drop ALL.- Add only those capabilities your application needs indeed (if any) with e.g.
--cap-add CHOWN. - Avoid capabilitiy
SYS_ADMINthat would allow root-like powers. - Compare
man capabilitiesand docker documentation about capabilities.
- Add only those capabilities your application needs indeed (if any) with e.g.
- Forbid gaining privileges in container (e.g. with
su) with option--security-opt no-new-privileges. - Mount container root file system read-only and only allow rw access for
/tmpwith--read-only --tmpfs /tmp. - Do NOT use
--privileged. If you want to give access to specific devices, use e.g.--device /dev/snd.