Hadolint Dockerfile linter
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
hadolint Dockerfile
hadolint - < Dockerfile
--ignore DL3008-t error-f json--trusted-registry <host>
.hadolint.yaml# hadolint ignore=DL3006
Concepts
- Dockerfile file or stdin
- DL rules build best practices
- ShellCheck SC rules on shell
- Report tty, json, sarif, ...
- Exit code 0 or 1
Run it
hadolint <Dockerfile>
hadolint <Dockerfile> <Dockerfile2>
hadolint - < Dockerfile
docker run --rm -i hadolint/hadolint < Dockerfile
podman run --rm -i docker.io/hadolint/hadolint <
Dockerfile
docker run --rm -i -v
"$PWD/.hadolint.yaml:/.config/hadolint.yaml"
hadolint/hadolint < Dockerfile
hadolint --version
hadolint --helphadolint -V <Dockerfile>
brew install hadolint
scoop install hadolint
Rules and severity
--ignore <RULE>
--error <RULE>
--warning <RULE>
--info <RULE>
--style <RULE>
--trusted-registry <host>
--require-label <label>:<type>
--strict-labels--disable-ignore-pragma
Failure and output
-t <level> / --failure-threshold <level>
--no-fail-f <format>
-f json-f sarif-f checkstyle-f codeclimate / -f gitlab_codeclimate
-f gnu-f sonarqube / -f junit / -f codacy
--no-color--file-path-in-report <path>
Inline pragmas
# hadolint ignore=<RULE>
# hadolint ignore=<RULE1>,<RULE2>
# hadolint global ignore=<RULE>
# hadolint shell=<shell>
Config file
.hadolint.yaml-c <file> / --config <file>
ignored: [DL3008, DL3059]
trustedRegistries: [docker.io]
failure-threshold: warning
override: {error: [DL3010]}
label-schema: {version: semver}
format: json$XDG_CONFIG_HOME/hadolint.yaml
HADOLINT_IGNORE=<RULES>
HADOLINT_NOFAIL=1
Common rules
DL3006DL3007DL3008DL3009DL3015DL3002DL3003DL3020DL3059DL4006SC2086Recipes
hadolint -t warning Dockerfile
# .hadolint.yamlignored: - DL3008trustedRegistries: - docker.io - ghcr.iofailure-threshold: warning
find . -name 'Dockerfile*' -print0 \ | xargs -0 hadolint -f json > hadolint.json
# hadolint ignore=DL3008RUN apt-get update && apt-get install -y curl



