hadolint
A linter for Dockerfiles that flags risky or sloppy instructions, such as running as root or using an unpinned latest tag.
In more detail
Each finding has a rule code: DL3002 means the last USER is root, and DL3007 means an image uses the latest tag. It also runs ShellCheck on the commands inside RUN lines. Running it in the pipeline catches these problems before an image is built.
Example
hadolint DockerfileRelated terms
- Dockerfile — A text file of instructions, such as FROM, COPY and RUN, that tells Docker how to build an image.
- ShellCheck — A linter for shell scripts that reports quoting mistakes, portability problems and common bugs, each with a numbered code.
Taught in
- Minimal Base Images: Less To Attack — Certified Kubernetes Security Specialist (CKS) Exam Prep
- Pin It, Lint It, Prove It: Images And Runtimes — Kubernetes and Cloud Native Associate (KCNA) Exam Prep
- Two Managers Down: The Night The Swarm Froze — Docker Certified Associate (DCA) Exam Prep
- Twelve Lines, Ten Warnings: Dockerfile Instructions And hadolint — Docker Certified Associate (DCA) Exam Prep
- Images Sprint: Eight Questions On Builds, Tags And Registries — Docker Certified Associate (DCA) Exam Prep
- Security Sprint: Eight Questions On Defaults, Trust And Access — Docker Certified Associate (DCA) Exam Prep