The host is read first: AA_HOST is set to 1 when the directory /sys/kernel/security/apparmor exists or /usr/sbin/aa-status is executable, and SE_HOST is set to 1 only when getenforce prints exactly Enforcing. With both at 0 the check WARNs about the host and never looks at a container. When AppArmor is present it then reads .AppArmorProfile and .HostConfig.SecurityOpt for each running container, and adds that container to an unconfined list when the profile is empty or the literal string unconfined and no SecurityOpt entry contains the text label. An empty unconfined list is the PASS; anything on it is the second WARN, which names the containers.
Needs a reachable daemon and at least one running container; otherwise SKIP. The host is assessed first: AppArmor counts as present if /sys/kernel/security/apparmor exists or /usr/sbin/aa-status is executable, SELinux only if getenforce prints exactly Enforcing. If neither, the check WARNs about the host and never examines containers.
Note an asymmetry in the per-container logic: containers are only inspected when AppArmor is present. On an SELinux-only host (RHEL family) the host test passes and the per-container loop finds nothing, so the result is PASS without any container having been individually checked. Note also that AppArmor's presence is detected from the filesystem, not from whether it is actually enforcing, and that the SELinux test is a plain text match on label, so --security-opt label=disable, which switches SELinux confinement off, counts as a label too.
| Result | When | What it means |
|---|---|---|
| SKIP | No running containers | Nothing was verified. No container was inspected and the host's AppArmor and SELinux state was never even read. |
| WARN | Neither AppArmor nor SELinux enforcing on the host | The host offers no mandatory access control at all, so no container on it can be confined; individual containers were not examined. |
| WARN | Some containers run without an AppArmor/SELinux profile | AppArmor is present on the host but the named containers are running outside it, with no profile and no SELinux label. |
| PASS | All confined | Every container the loop examined carries an AppArmor profile or an SELinux label option - on an SELinux-only host that loop examines none of them. |
Mandatory access control adds a second independent layer beyond capabilities/seccomp: Docker's docker-default AppArmor profile denies writes to /proc/sys, /sys, mounting, and ptrace of other processes; on SELinux hosts, container_t with MCS labels isolates containers from the host and from each other. OWASP Docker Cheat Sheet Rule #6; CIS Docker 5.1 "Ensure that, if applicable, an AppArmor Profile is enabled" and 5.2 (SELinux); NIST SP 800-190 4.4.
AppArmorProfileis empty when thedocker-defaultprofile could not be loaded (missingapparmoruserspace package,apparmor_parserabsent, or AppArmor disabled in the kernel command line).docker infoshowsapparmorunder Security Options when it is active.- On SELinux hosts (RHEL/Fedora), containers are confined by default only if Docker runs with
--selinux-enabled(daemon.json"selinux-enabled": true); many Docker CE installs on RHEL do not enable it, and this check does not inspect containers in that case (it reports PASS once SE_HOST=1). Podman enables SELinux by default. --security-opt apparmor=unconfinedor--privilegedproduceunconfined.- Any
SecurityOptentry containinglabelexempts a container from the AppArmor test, includinglabel=disable, which turns SELinux confinement off. - Debian 10+ and Ubuntu hosts ship with AppArmor enabled; Alpine and other minimal host distributions often do not.
Enable AppArmor on Debian or Ubuntu
sh sudo apt install apparmor apparmor-utilssudo systemctl enable --now apparmorsudo aa-status | grep docker-defaultsudo systemctl restart dockerDocker attaches
docker-defaultto every container it creates once AppArmor is available.- Alternative
Or enable SELinux labelling on RHEL-family hosts
Put SELinux in enforcing mode (
setenforce 1, andSELINUX=enforcingin/etc/selinux/config), then tell Docker CE to label containers:json { "selinux-enabled": true}Add that to
/etc/docker/daemon.json, restart Docker, and relabel bind mounts with:z(shared) or:Z(private) so containers can still read them. Remove apparmor=unconfined and label=disable
Delete these from
docker runcommands and from Composesecurity_optlists. Both switch confinement off for that container, and the second one hides it from this check.Write a custom profile where docker-default is too strict
If a workload fails under the default, find the exact denial with
journalctl -k | grep -i 'apparmor="DENIED"', write a profile that allows only that operation, and load it:sh sudo apparmor_parser -r /etc/apparmor.d/containers/myprofiledocker run --security-opt apparmor=myprofile ...Recreate the containers
The profile is attached when a container is created.
sh docker compose up -d --force-recreate
# Host side:sudo aa-status | head -3 # AppArmor: profiles loaded and in enforce modegetenforce # SELinux: expected Enforcingdocker info --format '{{.SecurityOptions}}'# Per container:docker inspect -f '{{.Name}} apparmor={{.AppArmorProfile}} opts={{.HostConfig.SecurityOpt}}' $(docker ps -q)# expected: docker-default (or a custom profile), never empty/unconfined, and no label=disable# The kernel's view from inside:docker exec <name> cat /proc/1/attr/current# expected: docker-default (enforce) - or an SELinux label such as system_u:system_r:container_t:s0:...- This one message covers two different cases: the audit could not reach the Docker daemon, or it reached it and nothing was running. Run
docker psas the audit user, thensudo docker ps. If both fail, the daemon is unreachable: checksystemctl status docker, then run the audit as root or give the account sudo. If they work but list nothing, there is genuinely nothing to evaluate, and a stopped container is never checked. The Docker Inventory check reports the two cases separately, so its result tells you which one you hit. - The host has no mandatory access control. On Debian/Ubuntu:
apt install apparmor apparmor-utils, ensureapparmor.serviceis enabled, and restart Docker so it appliesdocker-default. On RHEL family:setenforce 1and setSELINUX=enforcingin/etc/selinux/config. - Usually
--security-opt apparmor=unconfinedwas set to work around a denial. Fix the profile instead: checkjournalctl -k | grep -i 'apparmor="DENIED"'for the exact operation and write a custom profile. - The structural gap described above. Verify individually with
docker exec <name> cat /proc/1/attr/current, and confirmselinux-enabledis set withdocker info --format '{{.SecurityOptions}}', which should listname=selinux. - The check treats any
SecurityOptentry containinglabelas an SELinux label, solabel=disableexempts a container even though it disables confinement. List them withdocker inspect -f '{{.Name}} {{.HostConfig.SecurityOpt}}' $(docker ps -q) | grep label=disableand remove the option. - Presence is detected from the filesystem. Confirm the mode with
sudo aa-status, which reports how many profiles are in enforce versus complain mode. - The
docker-defaultprofile blocks some legitimate operations for unusual workloads. The denial appears injournalctl -k; write a targeted custom profile and load it withapparmor_parser -r, rather than reverting to unconfined.
