Docker Security Best Practices: Images, Runtime, and Supply Chain
Last reviewed . Tool versions and defaults may have changed since, so check the commands against current docs.
Harden container images and runtime. Image scanning, minimal base, and supply chain security.
On this page
Containers are a big attack surface. These practices reduce risk without slowing delivery.
1. Minimal and Updated Base Images
- Prefer distroless or Alpine; avoid full OS images when possible.
- Pin tags by digest and rebuild regularly for CVEs.
FROM golang:1.21-alpine AS builder
# build...
FROM gcr.io/distroless/static-debian12
COPY --from=builder /app /app
ENTRYPOINT ["/app"]
2. Non-Root and Read-Only
- Run as non-root (USER in Dockerfile; runAsNonRoot in Kubernetes).
- Use read-only root filesystem where possible; mount writable dirs only when needed.
3. Image Scanning
- Scan in CI (e.g. Trivy, Snyk) and block critical/high CVEs.
- Scan at runtime or in registry and alert on new findings.
4. Supply Chain
- Sign images (Cosign, Notary); verify in admission control.
- Prefer private registries and pin base image digests.
Making these standard for every image and deployment significantly improves your security posture.
Cite this article
Kiril Urbonas (2025). Docker Security Best Practices: Images, Runtime, and Supply Chain. DevOpsNess. https://www.devopsness.com/blog/docker-security-best-practices-images-runtime-and-supply-chain
[Docker Security Best Practices: Images, Runtime, and Supply Chain](https://www.devopsness.com/blog/docker-security-best-practices-images-runtime-and-supply-chain) (Kiril Urbonas, DevOpsNess, 2025-06-11)
More from DevOps
Explore more articles in this category
Docker Error Troubleshooting: The Complete Guide
Most Docker time is spent fighting the same handful of errors. This is the map: what each one means, the command that reveals the cause, and the fix.
OpenTelemetry Collector Pipelines: Production-Ready Configs
OTel Collector config patterns for the edge of every cluster: what lasts, what to rip out, and processors that quietly save money.
Practical Guide: Incident Response for Platform Teams
Platform teams own the systems that EVERY service depends on. An incident response playbook for when the foundation cracks.
You might have missed
Evergreen posts worth revisiting.