dockerfile-hardening-guide
Harden Dockerfiles for security and size — non-root users, pinned bases, multi-stage builds, minimal layers, and supply-chain hygiene.
Skill by anton-abyzov
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/anton-abyzov-dockerfile-hardening-guide
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/dockerfile-hardening-guide
What's inside
- Skill name
dockerfile-hardening-guide- Description
- Harden Dockerfiles for security and size — non-root users, pinned bases, multi-stage builds, minimal layers, and supply-chain hygiene.
- License
- MIT
- Instructions
- 95 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# dockerfile-hardening-guide Turn a working-but-risky Dockerfile into a small, reproducible, least-privilege image. Use this when reviewing or authoring container builds. ## Checklist ### Base image - **Pin by digest**, not a moving tag: `FROM node:20.14.0-bookworm-slim@sha256:...`. Tags like `latest` make builds non-reproducible. - Prefer `-slim` or `distroless` over full distros. Fewer packages means fewer CVEs and a smaller image. - Use multi-stage builds so compilers and dev dependencies never reach the runtime image. ### Run as non-root Containers default to UID 0. Create and switch to an unprivileged user: ```dockerfile RUN groupadd --gid 10001 app \ && useradd --uid 10001 --gid app --no-create-home app USER 10001:10001 ``` Use a numeric UID in `USER` so Kubernetes `runAsNonRoot` checks pass even if the username is not resolvable. ### Minimize layers and content - Combine related `RUN` steps and clean caches in the same layer: ```dockerfile RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/* ``` - Add a `.dockerignore` (`.git`, `node_modules`, `*.env`, `tests/`) so secrets and bulk never enter the build context. - Copy only what you need. `COPY . .` drags in everything. ### Secrets and build args - Never `ARG`/`ENV` a secret — it persists in image history and `docker history` reveals it. Use BuildKit secret mounts instead: ```dockerfile RUN --mount=type=secret,id=npmrc npm ci ``` - Do not bake tokens into layers. Inject runtime config via the orchestrator. ### Multi-stage example ```dockerfile # syntax=docker/dockerfile:1.7 FROM golang:1.22-bookworm@sha256:... AS build WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 go build -o /out/app ./cmd/app FROM gcr.io/distroless/static-debian12:nonroot COPY --from=build /out/app /app USER nonroot:nonroot ENTRYPOINT ["/app"] ``` ## Runtime hardening - Add a `HEALTHCHECK` so orchestrators detect a wedged process. - Set `WORKDIR` explicitly; never run from `/`. - Drop Linux capabilities and set a read-only root filesystem at the orchestrator level (`securityContext.readOnlyRootFilesystem: true`). ## Scoring table | Control | Risk if missing | Priority | |-------------------------|----------------------------|----------| | Non-root `USER` | container escape blast radius | high | | Pinned base digest | non-reproducible / poisoned base | high | | No secrets in layers | credential leak | high | | `.dockerignore` | secret/source leak, bloat | medium | | Multi-stage build | bloated attack surface | medium | | `HEALTHCHECK` | silent failures | low | ## Agent guidance - When reviewing, output a prioritized list (high → low), not a flat dump. - Verify the base image still builds after switching to `-slim`/distroless. - Confirm the app actually runs as the chosen UID before approving.
From anton-abyzov/vskill-test-public-skills-826, MIT.
More from anton-abyzov/vskill-test-public-skills-826
- 0.551score
private-skill-sharing-review
anton-abyzov
Review a proposed sharing or publishing workflow for a private AI skill using supplied repository visibility and authorization details.
SkillAFreshness: AClaude Code +9 - 0.551score
skill-inventory-drift
anton-abyzov
Compare supplied AI skill inventories from two machines or agents by source identity, version, content hash and installation scope.
SkillAFreshness: AClaude Code +9 - 0.551score
release-evidence-review
anton-abyzov
Review supplied software release receipts and state exactly which source, test, deployment, installation and runtime claims they support.
SkillAFreshness: AClaude Code +9 - 0.471score
conventional-commits-gatekeeper
anton-abyzov
Enforce and author Conventional Commits messages, validate commit history, and map commit types to semantic-version bumps.
SkillCFreshness: CClaude Code +9 - 0.471score
git-bisect-detective
anton-abyzov
Drive git bisect to find the exact commit that introduced a regression, including automated test scripts and merge-commit handling.
SkillCFreshness: CClaude Code +9 - 0.471score
http-api-mock-forge
anton-abyzov
Stand up deterministic HTTP API mocks for tests and local dev using MSW, Nock, or Prism — request matching, stateful handlers, and contract fidelity.
SkillCFreshness: CClaude Code +9 - 0.471score
scanner-tripwire-fixture
anton-abyzov
DELIBERATE security-scanner test fixture — contains intentionally dangerous patterns (curl-pipe-bash, env-var exfiltration).
SkillCFreshness: CClaude Code +9 - 0.471score
oss-dependency-triage
anton-abyzov
Triage third-party dependencies before adoption — maintenance health, security advisories, supply-chain risk, and a go/no-go scoring rubric.
SkillCFreshness: CClaude Code +9 - 0.471score
sql-query-review-lens
anton-abyzov
Review SQL queries for correctness, performance, and safety — index usage, N+1 patterns, injection risk, and EXPLAIN-driven tuning.
SkillCFreshness: CClaude Code +9 - 0.471score
oss-license-auditor
anton-abyzov
Audit a project's dependency licenses for compatibility and obligations — copyleft detection, license allowlists, and SPDX-based reporting.
SkillCFreshness: CClaude Code +9 - 0.471score
changelog-scribe
anton-abyzov
Generate and maintain a Keep a Changelog style CHANGELOG.md from Conventional Commits, grouped by type with correct semver headings.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jun 10, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from anton-abyzov
- 0.783score
glossary
anton-abyzov
Build the shared language - interview the user term by term and write GLOSSARY.md with what each term means in the business, the data, the code and the UI.
SkillAFreshness: A★ 167Claude Code +9 - 0.783score
sw-grill-me
anton-abyzov
Interview the user relentlessly, in rounds, until every decision in a plan is settled; facts are your job, decisions are theirs.
SkillAFreshness: A★ 167Claude Code +9 - 0.783score
grill-me
anton-abyzov
Interview the user relentlessly, in rounds, until every decision in a plan is settled; facts are your job, decisions are theirs.
SkillAFreshness: A★ 167Claude Code +9 - 0.783score
sw-glossary
anton-abyzov
Build the shared language - interview the user term by term and write GLOSSARY.md with what each term means in the business, the data, the code and the UI.
SkillAFreshness: A★ 167Claude Code +9 - 0.781score
handoff
anton-abyzov
Hand work to another tool, account or machine and pick it up there, in two words.
SkillAFreshness: A★ 167Claude Code +9 - 0.781score
sw-handoff
anton-abyzov
Hand work to another tool, account or machine and pick it up there, in two words.
SkillAFreshness: A★ 167Claude Code +9
Cite this page
dockerfile-hardening-guide skill. Agent Mart. https://agentmart.dev/skills/anton-abyzov-dockerfile-hardening-guide (last updated 2026-10-24)