dockerfile-best-practices

dockerfile-best-practices is a skill for Claude Code, Codex from obeone/claude-skills. It costs 53 tokens per session (3,499 once invoked), scanned A, original, MIT.

A guide for writing and improving Dockerfiles and Docker Compose files. Dockerfiles describe how to build container images, while Compose files define applications made of multiple containers.

In plain words
What is it for?
Choosing a Docker setup, using multi-stage builds and BuildKit cache mounts, running as a non-root user, adding image metadata, and checking Dockerfiles for problems.
Why use it?
It helps avoid slow builds, insecure containers, and unnecessarily large images by applying build, caching, and security practices.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions CLAUDE.md; mentions AGENTS.md.

Good fit Choosing a Docker setup, using multi-stage builds and BuildKit cache mounts, running as a non-root user, adding image metadata, and checking Dockerfiles for problems.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/obeone/claude-skills/dockerfile-best-practices
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.

Any agent
npx skills add obeone/claude-skills --skill dockerfile-best-practices
Clone the repo
git clone --depth 1 https://github.com/obeone/claude-skills

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/obeone/claude-skills/dockerfile-best-practices/github.svg)](https://agentmods.dev/skills/obeone/claude-skills/dockerfile-best-practices)
Your own site
<a href="https://agentmods.dev/skills/obeone/claude-skills/dockerfile-best-practices"><img src="https://agentmods.dev/badge/skills/obeone/claude-skills/dockerfile-best-practices/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-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/obeone/claude-skills/dockerfile-best-practices"><img src="https://agentmods.dev/badge/skills/obeone/claude-skills/dockerfile-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,499 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00053 $0.03499
Opus 5 $0.00026 $0.01750
Sonnet 5 $0.00011 $0.00700
Haiku 4.5 $0.00005 $0.00350

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

Security

Grade A, and why

dockerfile-best-practices scanned grade A with 1 finding 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 9d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (scripts/analyze_compose.py, scripts/analyze_dockerfile.py, scripts/extract_dockerfile_blocks.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Makes network callslowCapability

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

apt-get update && apt-get install -y --no-install-recommends curl
skills/dockerfile-best-practices/SKILL.md · 251 lines

How it starts

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

Dockerfile Best Practices

Comprehensive guide for creating optimized, secure, and fast Docker images using modern BuildKit features.

Workflow

  1. Identify language/framework → Pick a template from Language Templates
  2. Apply essential rules → Every Dockerfile must follow Essential Rules
  3. Security hardening → Non-root user, secret mounts, provenance and SBOM attestations (see references/supply_chain.md)
  4. Optimize for cache → Separate deps from code, use cache mounts
  5. Multi-stage if needed → Compiled languages or distroless runtime
  6. Add metadata → OCI labels, HEALTHCHECK, STOPSIGNAL (see PID 1 and Signals)
  7. Review → Run scripts/analyze_dockerfile.py, then docker build --check (see references/build_checks.md)

Essential Rules (Always Apply)

1. BuildKit syntax directive (first line, always)

# syntax=docker/dockerfile:1

2. Pin a readable tag you are willing to maintain

"Receives security patches" and "reproducible" are properties of a process, not of a tag string. A floating tag patches nothing by itself: it patches when someone rebuilds.

  • Pin a tag as specific as you are willing to maintain. python:3.12-slim is fine. python:3.12-slim-bookworm is equally fine: pinning the OS is a legitimate stability choice, not a mistake.
  • :latest and untagged images stay rejected. Not because mutability is uniquely evil there, but because they carry zero information about what you are actually running.
  • Every tag is mutable, and security updates come from rebuilding regularly. Rebuild in six months and you may get different bytes. A tag is documentation and a rough contract, not a reproducibility mechanism. Name the process, not the string.
  • Reproducibility comes from a process: digest pinning backed by Renovate or Dependabot, or recording the resolved digest in build metadata, which is what provenance attestations already do (references/supply_chain.md).
  • Digests are an option, not the default. Strongest guarantee available, but without renewal automation a digest is just a tag that rots silently while you ship known CVEs feeling safe. Most teams lack that automation. Adopt digests only with the tooling that renews them.

Read the full file on GitHub · 251 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. 9d ago First seen · 251 lines · 53 tokens per session scan A a866f8953356

Subscribe to this mod's changes

dockerfile-best-practices is a skill published in the GitHub repository obeone/claude-skills (3 stars, last pushed 4d ago), licensed MIT. It adds 53 tokens to every session and 3,499 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (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

docker-compose

Use this skill when authoring or editing Docker Compose files (compose.yaml / docker-compose.yml), running multi-container stacks, or containerizing a Drupal/PHP application — e.g. "set up a local Drupal stack with nginx and MariaDB", "add Redis to my compose file", "why won't my containers start", "split dev and prod…

siva01c/claude-plugins · 100 tokens

offensive-container-escape

Container escape and breakout techniques targeting Docker, containerd, and Podman runtimes. Covers privileged container breakout via host filesystem mount and nsenter, Docker socket abuse through /var/run/docker.sock, Linux capability exploitation including CAPSYSADMIN, CAPSYSPTRACE, and CAPNETADMIN, cgroup v1…

SnailSploit/Claude-Red · 196 tokens

datarobot-workload-api

Use when the user wants to create, configure, scale, debug, observe, or roll out container workloads on DataRobot's Workload API. Triggers include: deploying a container as a managed service, listing/starting/stopping workloads, changing replica counts or autoscaling, picking CPU/GPU compute bundles, injecting…

datarobot-oss/datarobot-agent-skills · 152 tokens

kubernetes

Use when deploying to or debugging Kubernetes. Covers workload configuration, resource requests and limits, probes, rollout strategy, networking, and the failure modes that produce CrashLoopBackOff and OOMKilled.

nimadorostkar/Claude-Skills-collection · 42 tokens

containers

Use when building or debugging container images. Covers multi-stage builds, layer caching, image size, non-root users, signal handling, and the security defaults most Dockerfiles get wrong.

nimadorostkar/Claude-Skills-collection · 38 tokens

tutor-setup

Transforms knowledge sources into an Obsidian StudyVault. Two modes: (1) Document Mode — PDF/text/web sources → study notes with practice questions. (2) Codebase Mode — source code project → onboarding vault for new developers. Mode is auto-detected based on project markers in CWD.

bevibing/tutor-skills · 66 tokens