Interview Prep/Docker/Image Security & Hardening

How does Hadolint help and what are examples of its rules?

BeginnerProductionImage Security & Hardening
Answer

Hadolint lints Dockerfiles (with ShellCheck on RUN scripts) and enforces best practice. Examples: DL3006 tag the base image, DL3008 pin apt versions, DL3009 delete apt lists, DL3025 use JSON for CMD, DL3002 last user should not be root.

hadolint Dockerfile
docker run --rm -i hadolint/hadolint < Dockerfile
All Docker questions Roadmap: Docker & containers

More on Image Security & Hardening