
Dockerfile Lint and Format Online: A Practical Hadolint Guide
Catch Docker anti-patterns and format Dockerfiles before CI with browser-based lint and format tools.
Linting and formatting a Dockerfile before CI
A Dockerfile builds your image layer by layer. A forgotten `USER root`, a floating `latest` tag, or cascading `RUN` steps bloat the image, hurt BuildKit cache hits, and fail Hadolint in CI, often too late. Formatting and linting before you open the PR cuts pipeline noise and keeps the team on the same conventions. On FastMinify you can lint a Dockerfile online (Hadolint-style DL rules) and format a Dockerfile online, fully in the browser. The full cluster lives on the online DevOps tools hub, next to Terraform, Compose, and `.env`.
Common DL rules and pre-PR workflow
A few codes show up in almost every team. Fixing them early avoids a wall of Hadolint warnings in CI.
Pin Hadolint (image or binary) and fail the pipeline on your severity policy. The browser remains a fast filter outside the monorepo.
Lint, format, and build compared
Format, lint, and `docker build` complement each other. In review, format, lint, and then let CI build.
Goal
When to use it
A simple sequence avoids fixing style after lint in a loop.
When the browser tool is enough
You do not need to clone the monorepo to fix three instructions pasted from Slack.
Limits of the browser and what it does not replace
You still need the CLI and CI once you require team config (ignores, severity), deep shell analysis in RUN, or multi-stage builds with BuildKit secrets.
A service often ships with Compose, `.env`, and HCL. Dockerfile format and lint, Compose and env validation, and Terraform format cover the daily DevOps path.
CLI and ecosystem
Hadolint and dockerfile-utils remain the enterprise standard. FastMinify tools complement exploration and one-shots.
Hadolint
Reference Dockerfile linter with DL rules and CI integration.
Pros:
Cons:
dockerfile-utils / formatters
Style normalization (casing, spacing) in the editor or CLI.
Pros:
Cons:
BuildKit / buildx
Modern build engine: cache, multi-platform, secrets.
Pros:
Cons:
Dockerfile anatomy, with its instructions and layers
A Dockerfile is a sequence of instructions (`FROM`, `RUN`, `COPY`, `WORKDIR`, `USER`, `CMD`…). Instructions that mutate the filesystem create layers. Order matters for cache, so frequent changes such as app code should come after stable layers such as OS packages. For neighboring YAML like `compose.yml`, validate the structure before `docker compose up`.
FastMinify's linter applies a documented subset of Hadolint DL rules (wiki IDs). It does not run ShellCheck inside every `RUN`, does not build the image, and does not talk to a remote registry. In CI, Hadolint CLI (or the GitHub Action) remains the team source of truth.
Lint and format are two distinct intents
The linter reports issues with DL codes (for example DL3007 for `latest` and DL3002 for a final root user) and Hadolint wiki links. It suits pasting a Dockerfile and fixing it before the PR. Try the online Dockerfile linter.
The formatter normalizes instruction casing and spacing for stable diffs, without changing build semantics. Use the online Dockerfile formatter before committing a hand-edited file.
A Dockerfile rarely ships alone. Also validate Docker Compose online and check `.env` files before a local deploy.
Conclusion
Linting and formatting a Dockerfile before CI avoids wasted round-trips on DL rules and style. Use the browser for excerpts and a first Hadolint-style filter, then Hadolint CLI and `docker build` for pipeline truth. Continue with Compose, `.env`, and Terraform on the same DevOps hub.
Lint or format your Dockerfile now
Related Articles

Paste a token and a JWKS to check an RS256, ES256 or HS256 signature in your browser. How kid picks the key, measured errors and the claims to check.

HTTP/2 and HTTP/3 change how files travel, not how big they are. Measured sizes, compile times and bundling tests show what minification still saves.

Convert a Unix epoch to a readable date and back, tell seconds from milliseconds, and avoid time zone, JWT and clock change traps, all in your browser.