AdvancedLesson 26 of 26
Dockerfile best-practice checklist
A short list to review before you ship.
- Pin base image versions (tag or digest); prefer slim or distroless.
- One main process per container; log to stdout.
- Order layers for caching; use
.dockerignore. - Multi-stage builds; do not ship compilers or tests.
- Run as non-root; no secrets in layers.
- Add a
HEALTHCHECK; use exec-formCMD/ENTRYPOINT. - Set labels (
org.opencontainers.image.source) and tag with version and commit. - Scan and rebuild on a schedule.