What is AppArmor, and what do its enforce and complain modes mean?
AppArmor is a Linux Mandatory Access Control framework that confines a program to a policy (which files, capabilities and network it may use). Enforce mode blocks anything outside the policy; complain mode only logs violations.
AppArmor is a Mandatory Access Control (MAC) framework built into Linux. Unlike ordinary (discretionary) file permissions, a MAC policy is imposed by the system and a program cannot step outside it, even as root. For containers it restricts, per profile:
- File access — which paths a program may read/write (e.g.
deny /tmp/** w,deny /etc/passwd rwklx). - Capabilities and network access.
Docker applies a basic docker-default profile to containers automatically (so Security Bench 5.2 shows PASS), but it is rudimentary — not enough for production.
A profile runs in one of two modes:
| Mode | Behaviour |
|---|---|
| enforce | Violations are blocked — the action is denied. |
| complain | Violations are allowed but logged — used to develop and tune a profile before enforcing it. |
docker-default runs in enforce mode. You write custom profiles (#include <tunables/global>, profile … { … deny … }), load them with apparmor_parser -r, and apply with --security-opt apparmor=<profile>. Check status with apparmor_status. A profile that denies writes to /tmp and all access to /etc/passwd means that even a compromised root process in the container simply cannot touch those paths.
Go deeper:
Wikipedia: AppArmor — the MAC framework and how profiles are enforced.
Docker Docs: AppArmor security profiles — the docker-default profile and writing your own.
SUSE: AppArmor profile components and syntax — the deny rules and permission flags explained.