Check a Dockerfile against best practices before it ships. Paste it, or drop several Dockerfiles at once, and get every problem by line — unpinned base images, layers that bust the cache, packages left behind by apt, secrets baked in with ENV, containers running as root, CMD in a form that ignores shutdown signals — each with a suggested fix. Multi-stage builds and line continuations are understood. It's free, runs in your browser, and nothing is uploaded.
| Problem | Fix |
|---|---|
| FROM image:latest | Pin a version or digest |
| COPY . . before npm ci | Copy manifests, install, then copy source |
| apt-get install without cleanup | && rm -rf /var/lib/apt/lists/* |
| No USER in final stage | Create a user; USER app before CMD |
| CMD npm start | CMD ["npm", "start"] |
| ENV API_KEY=… | RUN --mount=type=secret or runtime env |
latest changes whenever a new version is released, so the same Dockerfile can build a different image tomorrow. Pin a version.
Docker reuses a cached layer only if nothing before it changed. Copying all your code before installing dependencies means every code change reinstalls them.
ENV and ARG values are stored in the image and visible to anyone who pulls it. Use build secrets or runtime environment variables.
In shell form the command runs under /bin/sh, which doesn't forward SIGTERM, so the container is killed instead of shutting down cleanly.
It covers the most common rules in the browser. For CI, hadolint adds ShellCheck analysis of RUN commands.
No. It's linted in your browser.
The linter first parses the Dockerfile the way Docker does: backslash continuations are joined into one instruction, comment lines inside a continuation are dropped, and each instruction is tagged with the build stage it belongs to, so a later FROM build that names an earlier stage isn't mistaken for an unpinned image. Rules then run per instruction and per stage. They catch base images on :latest or with no tag; ADD used for local files; apt-get install without -y, without --no-install-recommends, without update in the same RUN or without removing /var/lib/apt/lists; apk without --no-cache; npm install instead of npm ci; pip without --no-cache-dir; curl piped into a shell; cd instead of WORKDIR; sudo; secrets assigned in ENV or ARG, which are baked into the image history; shell-form CMD and ENTRYPOINT, which stop signals reaching the process; invalid EXPOSE ports; relative WORKDIR; duplicate CMD or ENTRYPOINT; and COPY . . before the dependency install, which defeats layer caching. The final stage is checked for a non-root USER and a HEALTHCHECK. Each finding has a line number, a severity and a concrete fix.