dockerfile-best

dockerfile-best is a skill for Claude Code, Codex from cass-2003/local-workflow-skill. It costs 166 tokens per session (3,595 once invoked), scanned C, original, MIT.

Guidance for writing Dockerfiles, the recipe files used to build container images. It covers smaller images, cached build layers, non-root execution, health checks, security scanning, and builds for different processor types.

In plain words
What is it for?
Use it when creating or optimizing a Dockerfile, fixing slow builds, running containers safely, adding health checks, or preparing images for CI and multiple architectures.
Why use it?
It helps reduce image size and build time while avoiding common container security and process-management problems.

Skill for Claude CodeCodex

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

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cass-2003/local-workflow-skill/dockerfile-best
Any agent
npx skills add cass-2003/local-workflow-skill --skill dockerfile-best
Clone the repo
git clone --depth 1 https://github.com/cass-2003/local-workflow-skill

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-best

README.md
[![agentmods](https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dockerfile-best.svg)](https://agentmods.dev/skills/cass-2003/local-workflow-skill/dockerfile-best)
Your own site
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/dockerfile-best"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/dockerfile-best.svg" alt="Measured on agentmods" height="20"></a>
Per session 166 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,595 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. Scan, not verified.
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.00166 $0.03595
Opus 5 $0.00083 $0.01798
Sonnet 5 $0.00033 $0.00719
Haiku 4.5 $0.00017 $0.00360

Measured 5d ago against content hash 35994a22bf23, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade C, and why

dockerfile-best scanned grade C 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 5d 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 deletehighDestructive command

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

gcc libffi-dev && rm -rf /var/lib/apt/lists/*

Makes network callslowCapability

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

CMD wget --quiet --spider http://localhost:8080/healthz || exit 1
skills/backend-api/ours/dockerfile-best/SKILL.md · 399 lines

How it starts

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

Dockerfile Best Practices Skill — 镜像构建实战

何时使用

  • 写新 Dockerfile / 优化现有镜像
  • 镜像太大(> 1GB)需要瘦身
  • 排查 layer 缓存命中率低 / 构建慢
  • 容器以 root 跑 / 信号收不到 / 僵尸进程
  • CI 集成 SBOM / CVE 扫描 / 镜像签名

一、十条铁律

  1. Multi-stage build — build 阶段与运行阶段分离
  2. 最小 base image — distroless / scratch / alpine(按需)
  3. non-root user — 永不以 root 运行
  4. .dockerignore — 比 .gitignore 更严格
  5. 指令排序按变化频率 — 不变的在前,常变的在后(layer 缓存)
  6. 复制依赖清单先于源码package.jsonCOPY + install,再 COPY .
  7. COPY 不用 ADD(除非要解压 / URL)
  8. 明确 EXPOSE / HEALTHCHECK — 不依赖默认
  9. exec form CMDCMD ["node","app.js"] 而非 CMD node app.js
  10. pin 版本node:20.11.1-alpine3.19 而非 node:latest

二、Multi-stage 标准模板(Node.js)

# ================ Stage 1: deps ================
FROM node:20.11.1-alpine AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile --prod=false

# ================ Stage 2: build ================
FROM node:20.11.1-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN corepack enable && pnpm build && pnpm prune --prod

# ================ Stage 3: runner ================
FROM node:20.11.1-alpine AS runner
WORKDIR /app

# non-root
RUN addgroup -S app && adduser -S app -G app
USER app

# 仅拷贝运行时所需
COPY --from=builder --chown=app:app /app/node_modules ./node_modules
COPY --from=builder --chown=app:app /app/dist ./dist
COPY --from=builder --chown=app:app /app/package.json ./

ENV NODE_ENV=production
ENV PORT=8080
EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
  CMD wget --quiet --spider http://localhost:8080/healthz || exit 1

CMD ["node", "dist/server.js"]

三、Go 应用(极致小)

# ================ build ================
FROM golang:1.22-alpine AS build
WORKDIR /src

# 缓存 modules(独立 layer)
COPY go.mod go.sum ./
RUN go mod download

COPY . .
# 静态链接 + strip
RUN CGO_ENABLED=0 GOOS=linux go build \
    -ldflags="-s -w" \
    -trimpath \
    -o /out/app ./cmd/server

# ================ runtime ================
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/app /app
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/app"]

Read the full file on GitHub · 399 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. 5d ago First seen · 399 lines · 166 tokens per session scan C 35994a22bf23

Subscribe to this mod's changes

dockerfile-best is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 1mo ago), licensed MIT. It adds 166 tokens to every session and 3,595 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it C 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-30.

Related

Other skills, from other repositories

deploy-docker-compose

Run the Omnigent server as a Docker compose stack (server + Postgres) on any Docker host — your laptop, a VPS, EC2 by hand, or as the base layer of any container-platform deploy. Invoke when the user wants to build the image, bring up the compose stack, debug the stack on a host they already have, or extend the stack…

omnigent-ai/omnigent · 84 tokens

compute-env-setup

Set up a reproducible Feynman compute environment for research jobs. Use when a task needs Python/R packages, GPU libraries, containers, Modal, SSH, caches, or managed model runtime setup.

companion-inc/feynman · 45 tokens

securing-kubernetes-on-cloud

This skill covers hardening managed Kubernetes clusters on EKS, AKS, and GKE by implementing Pod Security Standards, network policies, workload identity, RBAC scoping, image admission controls, and runtime security monitoring. It addresses cloud-specific security features including IRSA for EKS, Workload Identity for…

xalgorix/xalgorix · 80 tokens

detecting-privilege-escalation-in-kubernetes-pods

Detect and prevent privilege escalation in Kubernetes pods by monitoring security contexts, capabilities, and syscall patterns with Falco and OPA policies.

xalgorix/xalgorix · 40 tokens

implementing-rbac-hardening-for-kubernetes

Harden Kubernetes Role-Based Access Control by implementing least-privilege policies, auditing role bindings, eliminating cluster-admin sprawl, and integrating external identity providers.

xalgorix/xalgorix · 41 tokens

docker-socket-mount

Docker / containerd socket mounted into a container → host RCE. Common in CI runners, GitOps controllers (ArgoCD, Flux), and 'Docker-in-Docker' setups. Single-command escape via docker run --rm --privileged -v /:/host alpine chroot /host.

PurpleAILAB/Decepticon · 67 tokens