Client Area
Votion Edge Simulation Node
DatabaseInfrastructureCloudPerformanceSecurity

Mastering Docker Seccomp & AppArmor Profiles (9770)

V
VOTION CORE CONTRIBUTOR
SYSTEM WRITER
12 min read

Introduction

Container security is no longer optional. As workloads move from VMs to Kubernetes, the attack surface shifts to the Linux kernel interface. Seccomp (secure computing mode) and AppArmor (application armor) are the two primary Linux Security Modules (LSMs) that Docker leverages to restrict what a container can do. This article walks you through designing, testing, and deploying custom profiles for production‑grade workloads—specifically targeting database engines (PostgreSQL, MySQL, MongoDB) that demand both performance and strict isolation.

Seccomp Deep Dive

Syscall Filtering Mechanics

Seccomp operates at the kernel level, intercepting each system call before execution. A profile is a JSON document that defines a defaultAction (allow, trap, kill, etc.) and a list of syscalls with per‑call actions. The kernel evaluates rules in order; the first match wins.

Profile Structure

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "architectures": ["SCMP_ARCH_X86_64", "SCMP_ARCH_X86"],
  "syscalls": [
    {"names": ["read", "write", "openat"], "action": "SCMP_ACT_ALLOW"},
    {"names": ["ptrace", "process_vm_readv"], "action": "SCMP_ACT_KILL"}
  ]
}

Use docker run --security-opt seccomp=profile.json to attach.

AppArmor Deep Dive

Path‑Based Confinement

AppArmor profiles are textual rulesets that confine an application to a specific set of filesystem paths, capabilities, and network families. Unlike Seccomp, AppArmor understands what the process tries to access, not just how it asks the kernel.

Profile Example for PostgreSQL

#include 
profile docker-postgresql {
  #include 
  #include 
  capability setgid,
  capability setuid,
  /var/lib/postgresql/** rw,
  /run/postgresql/** rw,
  /etc/postgresql/** r,
  /usr/lib/postgresql/** mr,
  network inet stream,
  deny /proc/** w,
  deny /sys/** w,
}

Load with apparmor_parser -r /etc/apparmor.d/docker-postgresql and run docker run --security-opt apparmor=docker-postgresql.

Hardware Performance Benchmark Telemetry
4.9x HIGHER THROUGHPUT
Votion Edge Bare-Metal Cluster420
Standard Virtual Hypervisor (AWS / GCP)85
METRIC: Random Disk IOPS (k)TELEMETRY: REAL-TIME HARDWARE HARDENING AUDIT
CODE_COMPILER // SECCOMP PROFILE GENERATION & TEST
V8_SANDBOX_LIVE
// Input Javascript:JS (ES6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Press Ctrl + Enter to run
// EXECUTION_LOGS:
[ Ready for execution context... ]

Building Profiles in CI/CD

Automate profile generation with syscall‑exporter (eBPF) to record syscalls during integration tests, then feed the trace into oci‑seccomp‑gen to produce a minimal allow‑list. For AppArmor, use aa‑logprof on staged audit logs. Store profiles as artifacts and inject them at deploy time via Helm values or Kustomize patches.

Cloud Compute Cost Calculator
SAVE UP TO 68% ANNUALLY
vCPU Cores (Dedicated):4 Cores
DDR5 RAM:16 GB
NVMe Gen4 Storage:256 GB
Anycast Egress Bandwidth:5 TB
Votion Cloud Estimate$52/moNo hidden ingress/egress fees
Legacy Cloud Estimate$166/moIncludes compute + egress tax
Net Annual Capital Retained$1,368Re-investable technical capital
CLI_BUILDER // VPS_DEPLOYMENT_COMPILER
READY_TO_DEPLOY
// Select Instance Parameters:
Instance Name:
Anycast Region:
vCPU Allocation:
RAM Memory:
NVMe Storage:
Operating System:
// Command Output Console:
[GENERATED_CMD]
votion deploy core-node-01 --cpu 8 --ram 16 --storage 250 --region fra-1 --os ubuntu-24
// CLI STATE VALIDATION:
Config check OK. Ready to pipe.
Anycast Network Topology Diagram
// NODE_TELEMETRY: LunarShield Scrubbing NodeLATENCY: 0.45ms
STATUS: Filtering 1.2Tbps Spectrum Buffer

eBPF/XDP kernel filter evaluates TCP/UDP frames directly on server NIC.

Testing & Debugging

  • Seccomp: Use strace -f -e trace=all inside the container; denied syscalls return EPERM.
  • AppArmor: Check dmesg | grep apparmor or aa-status for violations.
  • Integration: Run docker run --security-opt seccomp=unconfined --security-opt apparmor=unconfined to baseline, then re‑apply profiles and compare.

Best Practices & Pitfalls

  1. Start permissive, then tighten. Use SCMP_ACT_LOG to audit before enforcing.
  2. Version pin profiles. Store them alongside Dockerfiles; treat as code.
  3. Avoid over‑blocking. Database engines need futex, epoll, io_uring (if enabled).
  4. Combine with capabilities. Drop ALL and add only required caps.
  5. Monitor in production. Export Seccomp/AppArmor events to Prometheus via node_exporter + auditd.

Conclusion

Mastering Seccomp and AppArmor transforms Docker from a convenient packaging format into a hardened runtime. By codifying syscall and filesystem policies, you gain defense‑in‑depth that survives kernel exploits and supply‑chain compromises. The profiles showcased here are battle‑tested on high‑throughput PostgreSQL clusters running on Votion Cloud’s bare‑metal nodes—delivering sub‑millisecond overhead while eliminating entire classes of container breakout attacks.