How do you apply AppArmor or SELinux with Docker?
AdvancedScenarioSecurity and scanning
Answer
Situation read → Mandatory access control adds a second barrier.
What I'd do → Ubuntu: default docker-default AppArmor profile is applied automatically; custom: --security-opt apparmor=myprofile. RHEL/Fedora: enable "selinux-enabled": true in daemon.json, label mounts with :z/:Z, and keep container_t confinement.
Why → Even if processes escape other controls, MAC denies access outside policy.
Interview tip → Never run setenforce 0 to fix a mount error; fix labels.
More on Security and scanning
A scan reports 300 CVEs in your base image. How do you triage?IntermediateAdd vulnerability scanning to CI so critical findings block the merge.BeginnerWhy is mounting `/var/run/docker.sock` into a container dangerous?IntermediateA developer asks for `--privileged`. What do you do?IntermediateHarden a container run command for a stateless web API.IntermediateA pentester got root inside a container. How bad is it?Advanced