Container 03

AppArmor with Docker and Kubernetes


What is AppArmor?

  • AppArmor is a Linux security module that restricts programs’ capabilities with per-program profiles.
  • It controls what files, network, capabilities, and system calls a process (like a container) can access.
  • Helps reduce the attack surface by limiting what containers can do.

Using AppArmor with Docker

Step 1: Check if AppArmor is enabled

sudo aa-status

AppArmor on Amazon Linux?

Why aa-status is not found?

  • Amazon Linux does not come with AppArmor installed or enabled by default.
  • It primarily uses SELinux (Security-Enhanced Linux) as its Linux security module.
  • AppArmor is mainly found on Ubuntu, Debian, and SUSE-based distributions.
  • Red Hat-based distros (including Amazon Linux) use SELinux.

What does this mean?

  • You cannot use AppArmor commands like aa-status on Amazon Linux.
  • To use AppArmor, you would need a host running Ubuntu or Debian.
  • On Amazon Linux, SELinux is the default Mandatory Access Control system.

What should you do on Amazon Linux?

  • Explore and use SELinux for security policies.
  • Use SELinux with Docker and Kubernetes to enforce container security.
  • SELinux provides similar (sometimes more granular) control compared to AppArmor.

Want SELinux basics and examples?

I can help with:

  • Checking SELinux status
  • SELinux modes (Enforcing, Permissive, Disabled)
  • Managing SELinux policies
  • Using SELinux with Docker containers
  • Using SELinux with Kubernetes pods

AppArmor vs Seccomp

FeatureAppArmorSeccomp
Type of SecurityMandatory Access Control (MAC)System Call Filtering
ScopeControls file access, capabilities, network, and moreFilters and restricts Linux syscalls
GranularityFine-grained, based on file paths and permissionsFocused on syscall-level permissions
ConfigurationUses human-readable profiles defining allowed/denied file access, capabilities, and networkJSON-based profiles listing allowed or denied syscalls
Kernel ModuleLinux Security Module (LSM)Linux Kernel feature with seccomp-bpf filter
Use CasesRestrict container file system access, capabilities, and network usageLimit system calls to reduce attack surface (e.g., prevent dangerous syscalls)
ComplexityModerate complexity; profiles can be detailed and lengthySimple syscall lists, easier to manage
Enforcement ModesEnforce and complain modes (logs violations without blocking)Only enforce mode (blocks or allows syscalls)
Typical UsersContainer runtimes (Docker, Kubernetes), host securityContainer runtimes, sandboxed applications
Effect on PerformanceMinimal overheadVery low overhead

Summary

  • AppArmor focuses on file and resource access control, governing what a container can read/write, network access, and capabilities.
  • Seccomp focuses on restricting system calls a container can make, minimizing the attack surface at the syscall level.
  • Both complement each other and are often used together for defense in depth in container security.

Would you like me to provide examples or best practices for using them together?