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
More on Image Security & Hardening
Why should containers not run as root, and how do you enforce it?BeginnerWhat is a distroless image and what are the trade-offs?BeginnerHow do you scan an image with Trivy and fail a CI build on serious findings?BeginnerHow do you manage Trivy false positives and accepted risks?IntermediateWhich `docker run` flags make up a hardened runtime baseline?BeginnerWhat does `no-new-privileges` protect against?Beginner