- Home
- Skills
- DevOps & Cloud
- Dockerfile Linter: Security and image-size fixes
More screenshots
Works with the AI Agents you already use
Dockerfile Linter: Security and image-size fixes
Find the Dockerfile lines that slow your builds or widen your attack surface: unpinned bases, apt caches, root user, a COPY that busts the cache. Each finding comes with a line number and a fix.
$9
Dockerfile Linter: Security and image-size fixes
Example session with this skill installed
Review references/review.Dockerfile with --format markdown --fail-on warning and prioritize the fixes.
- Read your context and instructions
- Compiled the dockerfile linter
Dockerfile lint report
Files: 1 | Findings: 10 (error 0, warning 7, info 3) | Gate (--fail-on warning): FAIL
references/review.Dockerfile
Stages: debian:latest (line 2)
| Severity | Rule | Line | Finding | Fix |
|---|---|---|---|---|
| warning | DF001 | 2 | Base image has no tag or uses :latest: 'debian:latest' resolves to whatever :latest is at build time. | Pin an explicit version tag, e.g. FROM python:3.12-slim-bookworm. |
| info | DF013 | 2 | No HEALTHCHECK in the final stage: No active Dockerfile HEALTHCHECK found; review base-image health checks and orchestrator probes. | Add HEALTHCHECK CMD ["/app/healthcheck"] (or rely on your orchestrator's probes and ignore DF013). |
| warning | DF009 | 3 | apt-get update and install are not in the same RUN: apt-get update alone in a layer gets cached and goes stale for later installs. | Combine them: RUN apt-get update && apt-get install -y --no-install-recommends <pkgs> && rm -rf /var/lib/apt/lists/*. |
| warning | DF009 | 4 | apt-get update and install are not in the same RUN: Install runs with package lists from an earlier RUN; a cached older layer gives stale or missing packages. | Combine them: RUN apt-get update && apt-get install -y --no-install-recommends <pkgs> && rm -rf /var/lib/apt/lists/*. |
| warning | DF010 | 4 | apt-get install without -y: apt-get install will stop at the interactive confirmation prompt. | Add -y (non-interactive builds abort at the confirmation prompt). |
| info | DF007 | 4 | apt-get install without --no-install-recommends: apt-get install pulls in recommended packages by default. | Add --no-install-recommends to avoid pulling optional packages into the image. |
| info | DF008 | 4 | apt package lists not removed in the same RUN: /var/lib/apt/lists stays in this layer. | End the RUN with && rm -rf /var/lib/apt/lists/* (or use a BuildKit cache mount for /var/lib/apt). |
| warning | DF014 | 5 | Whole build context copied before installing dependencies: Dependencies are installed at line 6 after the whole context is copied, so any source edit re-runs the install. | Copy only the dependency manifests first (e.g. COPY package.json package-lock.json ./), install, then COPY . . |
| warning | DF003 | 7 | Final stage user is root or not declared: The last USER of the final stage is root. | Create an unprivileged user and switch to it before CMD, use separate RUN useradd -r -u 10001 app and USER 10001 instructions. |
| warning | DF016 | 8 | Shell-form CMD/ENTRYPOINT: Shell form runs under /bin/sh -c, which does not forward SIGTERM to your process. | Use exec form, e.g. CMD ["node", "server.js"], so the process is PID 1 and receives SIGTERM. |
Verdict: FAIL at the warning gate. Review the runtime user, combine apt update/install/cleanup, copy dependency manifests before the whole context, and check command form. No image was built or tested.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem You edit one source file and Docker reinstalls every dependency. Or a reviewer says "don't run as root" and "fix your apt layers" without pointing at lines. You want a short, specific list of what to change before the next build.
See it before you buy: real input, real output Command (from the package folder, exit code 1, 0.024 s):
python3 -I -B scripts/dockerfile_lint.py references/review.Dockerfile --format markdown --fail-on warning
Before: references/review.Dockerfile
# Lint-only example, not a runnable application.
FROM debian:latest
RUN apt-get update
RUN apt-get install curl
COPY . /app
RUN npm ci
USER root
CMD node /app/server.js
After: lines copied from the script's output (excerpt):
Files: 1 | Findings: 10 (error 0, warning 7, info 3) | Gate (--fail-on warning): **FAIL**
| warning | DF001 | 2 | Base image has no tag or uses :latest: 'debian:latest' resolves to whatever :latest is at build time. | Pin an explicit version tag, e.g. FROM python:3.12-slim-bookworm. |
| warning | DF009 | 3 | apt-get update and install are not in the same RUN: apt-get update alone in a layer gets cached and goes stale for later installs. | Combine them: RUN apt-get update && apt-get install -y --no-install-recommends <pkgs> && rm -rf /var/lib/apt/lists/*. |
| warning | DF014 | 5 | Whole build context copied before installing dependencies: Dependencies are installed at line 6 after the whole context is copied, so any source edit re-runs the install. | Copy only the dependency manifests first (e.g. COPY package.json package-lock.json ./), install, then COPY . . |
| warning | DF003 | 7 | Final stage user is root or not declared: The last USER of the final stage is root. | Create an unprivileged user and switch to it before CMD, use separate RUN useradd -r -u 10001 app and USER 10001 instructions. |
What the numbers show
- Ran on 7 public projects (94 Dockerfiles): 402 findings, with a median run time of 27 to 99 ms per project.
- Read 30 findings next to the source: 26 were accurate; the other 4 missed that a compiler was removed later in the same build.
- Honest limit: those 30 were a spot check covering every rule, not an accuracy rate. Render template files before linting (59 'errors' came from one Redis template).
What you get
- One Python script with 18 rules covering base-image tags, secrets in ENV/ARG, curl-pipe-to-shell, apt-get habits, the runtime user, HEALTHCHECK, command form and dependency cache order.
- A report in JSON or Markdown. Each finding has the file, line, rule ID, severity and a suggested fix.
- A pass/fail gate: pick error, warning, info or none. Skip rules you've decided don't apply with --ignore, and print every rule with --list-rules.
- Agent instructions: the agent reads each finding in context, puts the fixes in order, and asks about your base image or deployment only when that changes the advice.
- A rule guide with the known exceptions, example Dockerfiles, 37 test cases and five saved reports you can diff against a fresh run.
Measured on real data (full detail) I ran it on seven public projects at pinned commits: 94 Dockerfiles in total. Counts below are errors / warnings / info. Times are the median of five runs per project, including Python startup.
| Project (commit) | Files | Errors / warnings / info | Median time |
|---|---|---|---|
| black (e49fc44cef10) | 1 | 0 / 1 / 5 | 27 ms |
| docker-nginx (d99174e2cecf) | 16 | 0 / 16 / 43 | 50 ms |
| lemmy (dd033a3d243e) | 1 | 0 / 0 / 4 | 28 ms |
| node-express-realworld-example-app (30b68e1e8814) | 1 | 0 / 1 / 2 | 27 ms |
| postgres (dfc76bb299b0) | 24 | 0 / 24 / 60 | 84 ms |
| python (f4c67ece208d) | 40 | 0 / 40 / 103 | 99 ms |
| redis (30e7d6b51c8e) | 11 | 59 / 11 / 33 | 51 ms |
That's 402 findings: 59 errors, 93 warnings and 250 info. All 59 errors come from one Redis file that is a template, not a real Dockerfile. Its template tags look like unknown instructions. Leave it out and you get 339 findings across 93 real Dockerfiles. So render templates before you lint them.
I then read 30 of those findings next to the source. 26 were accurate. The other four said compilers stayed in the image, but the Dockerfile removed them later in the same build. I picked those 30 to cover every project and every rule that fired, so they're a spot check, not an accuracy rate. Findings about a missing USER or HEALTHCHECK are true of the file, but the base image or your orchestrator may already handle them.
Known limitations
- It doesn't build images, scan for CVEs, query registries, check digests or certify CIS compliance.
- It parses Dockerfile and shell syntax with heuristics. Complex variable expansion, ONBUILD and JSON-form RUN commands need a manual look.
- It treats the last stage as the runtime image and can't see USER or HEALTHCHECK set inside an external base image.
- Secret detection catches common token formats and secret-like names, not everything. Reports leave out instruction arguments, but paths and image names still show.
- The compiler rule (DF015) can be wrong when a later command in the same build removes the build packages.
Who it's for Developers and platform engineers who want a Dockerfile check that needs only Python, on a laptop or as a CI step. The agent explains each fix, makes the edits you ask for, and reruns the same gate.
Requires Python 3.8 or newer and UTF-8 Dockerfiles. Each file can be up to 2 MB, and each instruction (after joining continuation lines and heredocs) up to 65,536 characters. You don't need Docker or hadolint. The script is a single file with no dependencies.
Runs locally with no network, no telemetry and no file writes unless you redirect output.
Check it yourself 37 test cases and five saved sample reports, plus 74 side-by-side runs showing the current script gives the same output and exit codes as the original. To check it yourself from the package folder, run python3 -I -B scripts/dockerfile_lint.py references/good.Dockerfile --fail-on info (passes), then python3 -I -B scripts/dockerfile_lint.py references/review.Dockerfile --format markdown --fail-on warning and compare the output with references/sample-output/review.md. The test definitions are in references/checks.json.
Price and guarantee $9 one time, yours to use with any agent that can run Python. Covered by Agensi's money-back guarantee if it doesn't do what this page promises.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for DevOps & Cloud.
Heuristic-based linting only. No image building, CVE scanning, or registry lookups. Max file size 2MB. Does not support .dockerignore or full shell interpretation.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 15 days ago
- Software
Python