dockerfile-hardening

dockerfile-hardening is a skill for Claude Code from HermeticOrmus/LibreSecOps-Claude-Code. It costs 48 tokens per session (2,203 once invoked), scanned B, original, MIT.

A security guide for Dockerfiles, the files that describe how to build Docker container images. It covers image layers, safer base images, multi-stage builds, and build-time practices.

In plain words
What is it for?
Hardening Dockerfiles, choosing smaller or safer base images, keeping secrets out of image layers, and reducing the files sent during builds.
Why use it?
It explains how secrets, unnecessary files, vulnerable base images, and Docker image layers can create security risks.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is COPY src/ ./src/.

Part of the container-security plugin — 2 skills, 2 commands, 2 agents shipped together

Good fit Hardening Dockerfiles, choosing smaller or safer base images, keeping secrets out of image layers, and reducing the files sent during builds.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/HermeticOrmus/LibreSecOps-Claude-Code
agentmods
npx agentmods add skills/hermeticormus/libresecops-claude-code/dockerfile-hardening

Made for: Claude Code.

Or install container-security, the plugin that ships this one along with the rest of its 2 skills, 2 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dockerfile-hardening

README.md
[![agentmods](https://agentmods.dev/badge/skills/hermeticormus/libresecops-claude-code/dockerfile-hardening/github.svg)](https://agentmods.dev/skills/hermeticormus/libresecops-claude-code/dockerfile-hardening)
Your own site
<a href="https://agentmods.dev/skills/hermeticormus/libresecops-claude-code/dockerfile-hardening"><img src="https://agentmods.dev/badge/skills/hermeticormus/libresecops-claude-code/dockerfile-hardening/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dockerfile-hardening

Your own site · 80×15
<a href="https://agentmods.dev/skills/hermeticormus/libresecops-claude-code/dockerfile-hardening"><img src="https://agentmods.dev/badge/skills/hermeticormus/libresecops-claude-code/dockerfile-hardening.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,203 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00048 $0.02203
Opus 5.5 $0.00019 $0.00881
Sonnet 5.5 $0.00010 $0.00441
Haiku 4.5 $0.00005 $0.00220

Measured 1mo ago against content hash 7d5d73687a24, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

dockerfile-hardening scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletemediumDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

&& rm -rf /var/cache/apk/*

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
plugins/container-security/skills/dockerfile-hardening/SKILL.md · 260 lines

How it starts

The opening of the file, as written. The whole thing — 260 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Dockerfile Hardening

Secure Dockerfile patterns, multi-stage builds, minimal base images, and build-time security practices.

Knowledge Base

Container Image Security Model

A container image is a stack of filesystem layers. Each Dockerfile instruction creates a layer. Security implications:

  • Layers are permanent. Even if you RUN rm /secret in a later layer, the file exists in the layer where it was created. Anyone with docker history or dive can extract it.
  • Layers are shared. If two images share a base, they share layers. A vulnerability in the base affects all derived images.
  • The build context is sent to the daemon. Without .dockerignore, your entire directory (including .env, .git, node_modules) is sent to the Docker daemon.

Base Image Hierarchy (Most to Least Secure)

Base Size Packages Debug Tools Use Case
scratch 0 MB None None Statically compiled Go/Rust binaries
gcr.io/distroless/* 2-20 MB Runtime only (glibc, libssl) None Java, Python, Node.js runtimes
cgr.dev/chainguard/* 5-30 MB Minimal, hardened, daily-patched Minimal Production workloads needing updates
alpine 5 MB musl, busybox, apk Basic shell General purpose, small footprint
debian-slim 75 MB glibc, apt, basic utils Some When Alpine compatibility issues arise
ubuntu 75 MB Full distribution Full Development, not recommended for production

Patterns

Pattern 1: Multi-Stage Build (Node.js)

# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app

# Install dependencies first (cache optimization)
COPY package.json package-lock.json ./
RUN npm ci --only=production

# Copy source and build
COPY src/ ./src/
COPY tsconfig.json ./
RUN npm run build

# Stage 2: Runtime (distroless)
FROM gcr.io/distroless/nodejs22-debian12:nonroot
WORKDIR /app

# Copy only production artifacts
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist

# Distroless already runs as nonroot (uid 65532)
EXPOSE 3000
CMD ["dist/server.js"]

Read the full file on GitHub · 260 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago Changed · +5 lines · +48 tokens per session 7d5d73687a24
  2. 3mo ago First seen · 255 lines · 0 tokens per session scan B 78b1db6c1558

Subscribe to this mod's changes

dockerfile-hardening is a skill published in the GitHub repository HermeticOrmus/LibreSecOps-Claude-Code (4 stars, last pushed 1mo ago), licensed MIT. It adds 48 tokens to every session and 2,203 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 2 findings (recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

dockerfile-hardening compared with skills from other repositories

dockerfile-hardening next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
dockerfile-hardeningHermeticOrmus/LibreSecOps-Claude-CodeSkill41mo agoMITB48Claude Code
building-devsecops-pipeline-with-gitlab-ciadriannoes/awesome-agentic-aiSkill1082d agoMITA43Claude Code, Codex
building-devsecops-pipeline-with-gitlab-ci26zl/cybersec-toolkitSkill1134d agoMITA101Claude Code
building-devsecops-pipeline-with-gitlab-ciautohandai/community-skillsSkill144mo agoApache-2.0A43Claude Code, Codex
building-devsecops-pipeline-with-gitlab-ciNjones17/AI-agent-master-cyber-skills-listSkill278mo agononeA43Claude Code, Codex
building-devsecops-pipeline-with-gitlab-ciRobotFlow-Labs/skills-repoSkill28mo agononeA43Claude Code, Codex
implementing-devsecops-security-scanningxalgorix/xalgorixSkill1.5kyesterdayApache-2.0A109Claude Code, Codex