- Home
- Skills
- DevOps & Cloud
- Dockerfile Hardening
Works with the AI Agents you already use
Dockerfile Hardening
Non-root, pinned, multi-stage images, built under a new tag and smoke-tested before you ship.
$9
Dockerfile Hardening
Example session with this skill installed
Request: "Harden this Dockerfile before we ship it. The image is huge and I think it runs as root."
- Read your context and instructions
- Compiled the dockerfile hardening
The agent audits the Dockerfile first
$ scripts/dockerfile_audit.py Dockerfile
ERROR L1 unpinned-base Base image 'python:latest' has no tag or uses 'latest'. Pin a version.
ERROR L1 runs-as-root Final stage has no USER: the container runs as root.
ERROR L3 secret-in-env ENV 'DB_PASSWORD' looks like a secret; it is stored in image layers/history.
ERROR L4 secret-in-arg ARG 'GITHUB_TOKEN' looks like a secret; it is stored in image layers/history.
ERROR L6 curl-pipe-shell Piping a download into a shell: unverified remote code execution at build time.
ERROR L8 chmod-777 World-writable permissions.
WARNING L1 single-stage-build Build tooling in a single-stage image; use a multi-stage build.
WARNING L10 copy-all-no-dockerignore COPY . with no .dockerignore: .git, .env and local secrets may end up in the image.
WARNING L11 ssh-exposed Port 22 exposed; containers should not run SSH daemons.
Summary: 6 error(s), 8 warning(s), 4 info
Result: the agent rewrites it as a multi-stage build from a pinned python:3.12-slim base, with a non-root USER, secrets passed with RUN --mount=type=secret, a .dockerignore, an exec-form CMD and a HEALTHCHECK. It builds the result under a new tag (your current image stays untouched), compares size and layers with the old image, and runs a locked-down smoke test (no network, read-only filesystem, all capabilities dropped) before saying it is ready to ship.
Connects securely to your tools. The creator never sees your data.
About this skill
Hardened, provable Dockerfiles: a stdlib linter with 25+ checks (root user, unpinned bases, secrets in ENV/ARG, curl-pipe-shell, chmod 777, missing .dockerignore), multi-stage templates, a build under a new tag so the old image stays untouched, a read-only image comparison and a locked-down smoke test (no network, read-only filesystem, no capabilities). Smaller, non-root images without guessing whether they still start.
Why this instead of a free prompt
Free skills ask the model to "be careful". These ship executable gates: a migration that would lock a busy table fails the linter; an alert that references a metric your Prometheus does not have fails verification; a Compose rollout that turns unhealthy rolls itself back. Every script was run against real PostgreSQL 16, Docker 29, ansible-core and Prometheus with node_exporter and postgres_exporter before release.
How it keeps you safe
- Read-only pre-flight first: diagnostics that change nothing.
- Dry-run by default. Anything that changes state needs an explicit apply step and a typed confirmation.
- Rollback built in, and guardrails that refuse unsafe input.
- No secrets printed in output.
Requirements
Python 3.8+, Docker Engine (for the build/compare/smoke-test step). Runs on RHEL/AlmaLinux 8+ and Debian 11+/Ubuntu 20.04+.
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.
Not for: docker-compose files (use compose-production-audit), Kubernetes manifests or Helm charts. Requires Python 3.8+, plus Docker Engine for the build, compare and smoke-test step, on Linux (RHEL/AlmaLinux 8+, Debian 11+/Ubuntu 20.04+).
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 5 days ago
- Software
Python 3.8+Docker Engine