container-image-hardening — Claude Code skill: what it does
container-image-hardening audits Dockerfiles and built images for production safety, then hands back a hardened build. Run it before a container ships.
no license 235 installs updated 2026-08-26
npx skills add securityskills/skills --skill container-image-hardening -a claude-codeWhat container-image-hardening does
The skill walks a Dockerfile against a fixed checklist. It asks which base image you started from and whether the tag or digest is pinned rather than latest, checks that compilers and package managers stayed out of the final stage, confirms a dedicated USER with its own UID, and looks for credentials in ENV blocks or a copied .env. Dependency pinning through lockfiles gets a look too, along with healthchecks and how apt layers were combined.
Scanning relies on tools you already have: trivy image, grype, docker scout cves. The skill sets up a build gate that fails CI when critical CVEs have a fix available, and it flags base image updates through renovate or dependabot. Verification uses docker history, dive and docker run --rm <image> id, where that last command reveals whether the process runs as root. Miss those utilities in your environment and the scan and inspect steps simply won't run.
What comes back: a rewritten Dockerfile, scan results from before and after the changes, and the CI gate config. For runtime the skill writes launch settings — read-only root filesystem, every capability dropped, no new privileges allowed, tmpfs mounted where writes are needed.
What it helps with
- strip build toolchains from the final image stage
- catch secrets baked into image layers
- run the container under a dedicated non-root UID
- fail the pipeline on critical CVEs
- lock the root filesystem to read-only
Example prompts for the agent
- Review my
Dockerfileand rewrite it against the hardening checklist - Add a
trivy image --severity HIGH,CRITICAL --exit-code 1step to CI for this image - Set up the container to run with
read_only: trueand dropped capabilities
How to install container-image-hardening
1Skills CLI (Vercel)
npx skills add securityskills/skills --skill container-image-hardening -a claude-code2Manually: put the files in place
~/.claude/skills/container-image-hardening/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/container-image-hardening/
1Skills CLI (Vercel)
npx skills add securityskills/skills --skill container-image-hardening -a codex2Manually: put the files in place
.agents/skills/container-image-hardening/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add securityskills/skills --skill container-image-hardening -a cursor2Manually: put the files in place
.cursor/skills/container-image-hardening/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install securityskills/skills container-security/docker/container-image-hardening2Manually: put the files in place
.github/skills/container-image-hardening/SKILL.md1Skills CLI (Vercel)
npx skills add securityskills/skills --skill container-image-hardening -a gemini-cli2Platform CLI
gemini skills install https://github.com/securityskills/skills --path container-security/docker/container-image-hardeningManually: put the files in place
.devin/skills/container-image-hardening/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add securityskills/skills --skill container-image-hardening -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about container-image-hardening
How do I install container-image-hardening in Claude Code?
Run npx skills add securityskills/skills --skill container-image-hardening -a claude-code. The skill file lands at ~/.claude/skills/container-image-hardening/SKILL.md.
What does container-image-hardening do?
It reviews a Dockerfile for security issues and returns a fixed build, a scan report and a CI gate configuration.
Which tools does the image scan need?
The skill calls trivy, grype, docker scout, dive and docker history. Without them the scanning and layer inspection steps cannot complete.