What does Hadolint do and how do you use it in a pipeline?
BeginnerScenarioContainer and IaC Security
Answer
Situation read → Hadolint lints Dockerfiles for bad practices, and embeds ShellCheck for RUN lines.
What I'd do →
- Run locally or in CI:
hadolint Dockerfileordocker run --rm -i hadolint/hadolint < Dockerfile. - Fail on warnings and above:
hadolint --failure-threshold warning Dockerfile. - Store exceptions in
.hadolint.yamlwith comments. - Typical catches: missing
USER(DL3002), unpinned versions (DL3008),ADDinstead ofCOPY(DL3020).
Why → It is fast and catches issues before the image is even built.
Interview tip → Pair it with image scanning; they find different problems.
More on Container and IaC Security
A team asks whether to use `ubuntu`, `alpine` or a distroless base image. How do you advise?Beginner`trivy image` shows 300 vulnerabilities in your app image. How do you bring this down?BeginnerA Dockerfile runs the app as root. How do you fix it and prove the fix?IntermediateCheckov fails a Terraform PR because an S3 bucket allows public access. What do you change?BeginnerHow do you set up image scanning so nothing vulnerable reaches production?IntermediateAn image passed scanning three weeks ago and runs in production. A new critical CVE is published today. What happens next?Intermediate