Docker & Podman Security
Harden container runtime configuration, daemon access and image build practices.
IntermediateDocker SecurityContainerInfrastructure
Where it fits in the lifecycle
- Plan
- Code
- Build
- Test
- Release
- Deploy
- Operate
- Monitor
- Build Dependency scanning, image scanning, SBOM generation and signing.
- Deploy Policy enforcement, admission control and infrastructure security.
Overview
Container isolation depends on kernel features being configured correctly. Rootless runtimes, dropped capabilities, seccomp profiles and read-only filesystems close the common escape paths.
Why it matters
Access to the Docker daemon socket is equivalent to root on the host, and privileged containers remove most isolation.
How it works
- 01Run the runtime rootless where possible.
- 02Drop all capabilities and add back only what is required.
- 03Apply seccomp and mount the root filesystem read-only.
- 04Never expose the daemon socket to workloads.
Common tools
Docker BenchPodmanTrivyDockerPodmanLinux
Implementation examples
bashConstrained container run
podman run --rm \ --user 10001:10001 \ --cap-drop=ALL \ --read-only \ --security-opt no-new-privileges \ --tmpfs /tmp \ app:1.4.2Best practices
- Prefer rootless runtimes.
- Never mount the daemon socket into a container.
- Use multi-stage builds to drop build tooling.
Common mistakes
- Using `--privileged` to work around a permission error.
Hands-on labs
- Lab 01 — Scan a Container Image
Scan a public container image with Trivy and interpret the findings.
- Lab 05 — Restrict Pod Privileges
Apply Pod Security Admission and fix a workload that fails the restricted profile.