Skip to main content

Security Hardening

Container security is about reducing the blast radius if an application is compromised. Docker containers share the host kernel, so without hardening an attacker who escapes a container gains access to everything.

Defense in Depth

flowchart TD
A["Application Code<br/>Secure dependencies, input validation"] --> B["Container Runtime<br/>Non-root, drop capabilities, read-only FS"]
B --> C["Image Supply Chain<br/>Minimal base, scan CVEs, pin digests"]
C --> D["Host & Network<br/>Firewall, private networks, log monitoring"]

style A fill:#e8f5e9,stroke:#2e7d32
style B fill:#e3f2fd,stroke:#1565c0
style C fill:#fff3e0,stroke:#ef6c00
style D fill:#f3e5f5,stroke:#7b1fa2

What You Will Learn

LessonWhat It Covers
Container Security BasicsNon-root users, capabilities, read-only filesystems
Image SecurityMinimal base images, vulnerability scanning, digest pinning
Secrets ManagementFile-based secrets, environment variable risks, Compose secrets
Security Audit ChecklistActionable pre-deployment security review

The Golden Rule

Every container should run with the minimum privileges needed to function. If it does not need root, do not give it root. If it does not need a capability, drop it.

Prerequisites

  • Understand Dockerfiles and image building (Module 3)
  • Understand Docker Compose (Module 7)