dockerfile-hardening

dockerfile-hardening is a skill for Claude Code, Codex from HermeticOrmus/LibreSecOps-Claude-Code. It costs 0 tokens per session (2,147 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 CodeCodex

Written for no agent in particular: nothing here depends on one.

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

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, Codex.

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,147 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.00000 $0.02147
Opus 5 $0.00000 $0.01073
Sonnet 5 $0.00000 $0.00429
Haiku 4.5 $0.00000 $0.00215

Measured 7d ago against content hash 78b1db6c1558, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 7d 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 · 255 lines

How it starts

The opening of the file, as written. The whole thing — 255 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 · 255 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. 7d 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 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,147 tokens. 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

Other skills, from other repositories

building-devsecops-pipeline-with-gitlab-ci

Design and implement a comprehensive DevSecOps pipeline in GitLab CI/CD integrating SAST, DAST, container scanning, dependency scanning, and secret detection.

26zl/cybersec-toolkit · 43 tokens

building-devsecops-pipeline-with-gitlab-ci

Design and implement a comprehensive DevSecOps pipeline in GitLab CI/CD integrating SAST, DAST, container scanning, dependency scanning, and secret detection.

adriannoes/awesome-agentic-ai · 43 tokens

building-devsecops-pipeline-with-gitlab-ci

Design and implement a comprehensive DevSecOps pipeline in GitLab CI/CD integrating SAST, DAST, container scanning, dependency scanning, and secret detection.

autohandai/community-skills · 43 tokens

building-devsecops-pipeline-with-gitlab-ci

Design and implement a comprehensive DevSecOps pipeline in GitLab CI/CD integrating SAST, DAST, container scanning, dependency scanning, and secret detection.

Njones17/AI-agent-master-cyber-skills-list · 43 tokens

building-devsecops-pipeline-with-gitlab-ci

Design and implement a comprehensive DevSecOps pipeline in GitLab CI/CD integrating SAST, DAST, container scanning, dependency scanning, and secret detection.

RobotFlow-Labs/skills-repo · 43 tokens

implementing-devsecops-security-scanning

Integrates Static Application Security Testing (SAST), Dynamic Application Security Testing (DAST), and Software Composition Analysis (SCA) into CI/CD pipelines using open-source tools. Covers Semgrep for SAST, Trivy for SCA and container scanning, OWASP ZAP for DAST, and Gitleaks for secrets detection. Activates for…

xalgorix/xalgorix · 109 tokens