Dockerfile Linter

Check a Dockerfile against common best practices

Runs in your browserDebugging01Formatters & Validators

What is Dockerfile Linter?

A Dockerfile linter applies ten high-frequency best-practice rules covering base image tags, the choice between ADD and COPY, apt-get usage, layer count, non-root users, and health checks, and cites the matching hadolint rule code for every finding. Linting runs entirely in your browser.

How to use Dockerfile Linter

  1. 1Paste your Dockerfile content.
  2. 2Review the findings on the right, handling warning-level issues first.
  3. 3Turn on "warnings only" to filter out informational suggestions.
  4. 4Wire hadolint into CI when you need the full rule set.

How do I do this in code?

Use the tool above for one-off work; for anything you repeat, move it into a script or your project.

# Official image, ready to run in CI as-is
docker run --rm -i hadolint/hadolint < Dockerfile

# Fail only on warnings and above
docker run --rm -i hadolint/hadolint hadolint --failure-threshold warning - < Dockerfile

Common errors and how to fix them

SymptomCauseFix
apt-get fails with "Unable to locate package" during the buildapt-get update and apt-get install live in separate RUN instructions, so the cached update layer leaves the package index stale.Combine update and install into a single RUN, and clean up /var/lib/apt/lists at the end of it.
Files in the container are owned by root, breaking permissions on mounted volumesThere is no USER instruction, so the process runs as root.Create an unprivileged user and switch to it with USER before CMD.

Frequently asked questions

Do the rule codes match hadolint?+

They do, so you can look up the original rule and its full explanation by code. This tool implements only the ten most common rules and is not a drop-in replacement for hadolint, so production projects should still run hadolint in CI.

Why is combining RUN instructions recommended?+

Every RUN produces an image layer. More layers means a larger image and slower pulls, and files deleted in a later layer never actually disappear from the image. Joining related commands with && and cleaning up within the same layer is the only way to genuinely reduce size.

Related tools

All tools