Dockerfile Linter
Check a Dockerfile against common best practices
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
- 1Paste your Dockerfile content.
- 2Review the findings on the right, handling warning-level issues first.
- 3Turn on "warnings only" to filter out informational suggestions.
- 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
| Symptom | Cause | Fix |
|---|---|---|
| apt-get fails with "Unable to locate package" during the build | apt-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 volumes | There 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 toolsJSON Formatter
Format, minify, and validate JSON with line-and-column error reporting
JSON Validator
Validate JSON syntax and pinpoint the failing line and column
JSON Viewer
Explore JSON as a collapsible tree and read off access paths
JSON Escape / Unescape
Escape and unescape JSON strings
SQL Formatter
Beautify SQL per dialect, including MySQL and PostgreSQL
XML Formatter
Pretty-print or minify XML while checking that every tag is closed