Pcornel
Security

Container Security

Cheat sheet · https://pcornel.dk/topic.php?topic=5034

Back to the Topic

Answer

Container security protects images, registries and running containers: minimal and scanned images, no secrets in images, non-root and rootless containers, dropped capabilities, seccomp profiles and runtime monitoring.

Remember

  • Containers share the host kernel; isolation is weaker than VMs.
  • Running as root or privileged makes escapes easier.
  • Images often carry known vulnerabilities and secrets.

First checks

  • trivy image <image> — image vulnerabilities
  • docker inspect <container> --format '{{.HostConfig.Privileged}} {{.Config.User}}' — privileged/user
  • kubectl get pods -A -o jsonpath='{..securityContext}' — security contexts

Commands

docker inspect

Verify in this order

image build → scan/sign → admission → runtime controls

Where it usually breaks

First mismatch in platform/workload identity → desired configuration → management/control plane → runtime enforcement → telemetry → workload/resource outcome; preserve identity/policy/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5034

Confirmation

Confirm action

Continue?