Dockerfile Linter
Lint Dockerfiles against hadolint-style rules: latest-tag pins, layer-cache misses, apt-get install patterns, root user, missing HEALTHCHECK, COPY vs ADD, multi-stage opportunities. Gives severity badges and fix snippets.
Dockerfile Linter
Dockerfile Linter
Hadolint-style rules: tag pinning, layer caching, apt-get patterns, root user, missing HEALTHCHECK, COPY vs ADD, multi-stage opportunities.
DL3007line 1Pin base image to a specific version or digest. ':latest' (or no tag) makes builds non-reproducible.
FROM node:24.04 # or @sha256:<digest>
MULTISTAGE-OPPORTUNITYline 1Build artifacts and runtime live in the same image. Multi-stage builds shrink the final image.
FROM node:24 AS build ... FROM node:24-slim COPY --from=build /app/dist ./dist
CACHE-ORDERline 5COPY . . before installing dependencies wastes the cache: any source change reruns install.
COPY package*.json ./ RUN npm ci COPY . .
DL3009line 7Delete the apt-get lists after installing to keep the image small.
RUN apt-get update && apt-get install -y --no-install-recommends pkg && rm -rf /var/lib/apt/lists/*
DL3015line 7Avoid recommended packages: pass --no-install-recommends to apt-get install.
apt-get install -y --no-install-recommends <pkg>
DL3008line 7Pin package versions in apt-get install (pkg=version).
apt-get install -y --no-install-recommends pkg=1.2.3
DL3009line 8Delete the apt-get lists after installing to keep the image small.
RUN apt-get update && apt-get install -y --no-install-recommends pkg && rm -rf /var/lib/apt/lists/*
DL3015line 8Avoid recommended packages: pass --no-install-recommends to apt-get install.
apt-get install -y --no-install-recommends <pkg>
DL3008line 8Pin package versions in apt-get install (pkg=version).
apt-get install -y --no-install-recommends pkg=1.2.3
DL3020line 10ADD with a URL skips checksum verification. Prefer RUN curl with explicit checksum.
RUN curl -fsSL <url> -o /tmp/file && echo "<sha256> /tmp/file" | sha256sum -c
DL3003line 12Use WORKDIR to switch directories instead of `cd` in a RUN.
WORKDIR /app
DL3002line 14Container ends up as root. Switch to a non-privileged user before CMD/ENTRYPOINT.
USER app
DL3025line 18Use JSON array form for CMD so signals (SIGTERM) propagate correctly.
CMD ["npm", "start"]
HEALTHCHECK-MISSINGline 18No HEALTHCHECK defined. Orchestrators rely on it to detect zombie containers.
HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost:3000/health || exit 1
Last updated:
This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.
For AI agents: how to call this tool
Machine-readable contract, endpoints and examples. Humans can ignore this section.
Best Path For Builders
Browser workflow
Runs instantly in the browser with private local processing and copy/export-ready output.
Browser Workflow
This tool is optimized for instant in-browser execution with local data handling. Run it here and copy/export the output directly.
/dockerfile-linter/
For automation planning, fetch the canonical contract at /api/tool/dockerfile-linter.json.
How to Use Dockerfile Linter
- 1
Paste your Dockerfile
Drop the full Dockerfile (multi-stage included) into the editor on the left. The linter parses FROM/RUN/COPY/ADD/USER/EXPOSE/HEALTHCHECK and tracks build stages, line continuations, and string interpolations.
- 2
Review findings by severity
Findings stream into the right panel grouped by severity — error, warning, info, style. Each finding shows the rule code, line number, and a one-sentence explanation of why the pattern matters in production.
- 3
Filter to focus
Click any severity card to filter findings down to that level. Useful for fixing all warnings first before chasing style issues, or reviewing only errors during a CI gate triage.
- 4
Copy fix snippets
Most rules ship a copy-ready fix snippet (pin versions, use --no-install-recommends, switch to JSON CMD form, add HEALTHCHECK). Click Copy on any snippet to paste it directly into the Dockerfile.
- 5
Track the score
The overall score (0–100) drops on each finding by severity weight. Aim for 80+ before merging — that range usually means non-root user, pinned base image, sensible layer order, and a HEALTHCHECK present.