Use this when reducing the attack surface of containers.
Container Hardening
Container hardening reduces attack surface: minimal base images, non-root users, read-only file systems, dropped capabilities, seccomp and AppArmor or SELinux profiles, and resource limits.
1. Container hardening: CIS benchmarks for hosts, runtimes and clusters.
2. Read-only rootfs, non-root, dropped caps, seccomp, resource limits.
3. Network policies default deny.
4. RBAC least privilege.
5. Patch nodes.
benchmark → config → scan → fix
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Common mistakes Narrow the fault
- Running with
--privilegedor the Docker socket mounted.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Minimal base images have fewer vulnerabilities.
- Run as non-root with a read-only file system.
- Drop all capabilities and add back only what is needed.
kube-bench run --targets node,master— CIS Kubernetesdocker-bench-security— CIS Docker- Restricted PSA + network policies — cluster hardening
ReferenceWhy it matters1 section · depth on demand
Check
docker run --rm --read-only --cap-drop ALL --security-opt no-new-privileges --user 10001 --pids-limit 100 --memory 256m app
Documented example, not captured output. Benchmark: docker-bench-security, CIS Docker/Kubernetes benchmarks, kube-bench.
ReferenceImportant terms & boundaries2 sections · depth on demand
How it works
Container hardening reduces what a compromised container can do: non-root user, read-only root filesystem, dropped capabilities, no privilege escalation, resource limits, and no access to the host's Docker socket or sensitive paths.
Checklist
- Minimal or distroless base images.
- Run as non-root (
USER 10001). - Read-only root file system.
- Drop all capabilities; add only needed ones.
no-new-privileges, seccomp default profile.- Resource limits (CPU/memory).
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Container Security → Container Hardening. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/sp/800/190/final · confidence 94%