Guide

THE TOOLBOX / CONTAINERS & DEVOPS

Dockerfile Linter & Generator —
Audit Container Security, Layer Caching & Multi-Stage Builds Locally.

Paste any Dockerfile to catch security risks, hardcoded secrets, :latest tags, and broken layer caches—or start from production-ready multi-stage templates for Next.js, Go, and Python.

Templates:
11 lines
Security & Cache Score
21 / 100
1 Errors5 Warnings3 Info
DL3007Avoid ":latest" tag on base image (node:latest).Line 1

Fix: Pin an explicit minor/patch version (e.g., node:22-alpine) for reproducible builds.

PERF01COPY . . appears before copying dependency manifests.Line 4

Fix: Copy package.json / requirements.txt / go.mod and install dependencies before COPY . . to preserve Docker layer cache.

DL3059Multiple consecutive RUN instructions increase image layers.Line 6

Fix: Combine related RUN commands with && to reduce final layer count.

DL3015apt-get install missing --no-install-recommends.Line 6

Fix: Add --no-install-recommends and clean up /var/lib/apt/lists/*.

DL3059Multiple consecutive RUN instructions increase image layers.Line 7

Fix: Combine related RUN commands with && to reduce final layer count.

DL3020Use COPY instead of ADD for local files.Line 8

Fix: Replace ADD with COPY unless auto-extracting a local tar archive.

DL3025Use JSON exec form for CMD (e.g., CMD ["node", "server.js"]).Line 10

Fix: Exec form avoids spawning /bin/sh so SIGTERM reaches your app cleanly.

DL3002Container runs as root (no USER instruction found).Line 11

Fix: Add a non-root USER (e.g., USER node or USER app) before CMD.

INFO01No HEALTHCHECK instruction defined.Line 11

Fix: Add a lightweight HEALTHCHECK so orchestrators detect unhealthy containers.

CONTAINER BEST PRACTICES

Related DevOps & Config Tools.

2. Exec Form vs. Shell Form

Always prefer CMD ["node", "server.js"] over CMD node server.js so PID 1 receives SIGTERM directly during rolling Kubernetes or Docker deployments.

Frequently Asked Questions

What Dockerfile mistakes does this linter catch?

It checks for unpinned :latest base images (DL3006/DL3007), missing non-root USER instructions (DL3002), hardcoded secrets in ENV/ARG (SEC001), ADD instead of COPY (DL3020), broken layer caching (COPY . . before package.json), shell-form CMD/ENTRYPOINT (DL3025), consecutive RUN layers (DL3059), and missing apt/apk cache cleanup flags.

Why should you use multi-stage Docker builds?

Multi-stage builds compile your app in a heavy SDK image (with compilers and devDependencies) and copy only the final binary or standalone bundle into a minimal runtime image (like Alpine or Distroless), often shrinking container size by 70%–95% and eliminating attack surface.

Is my Dockerfile uploaded to any server during linting?

No. All static analysis and multi-stage generation happen 100% locally in your browser with zero network calls.