dockerfile
Skill4 starsChanged 6 months agoMITView on GitHub
Write, review, and optimize Dockerfiles applying multi-stage builds, non-root constraints, layer caching, and strict image pinning.
- Deletes or force-pushes
- Installs packages
8 other projects use a version of this.
Adopted by
Most recently taken up by
- petr-korobeinikov/skillstheir own version, first seen Nov 8, 2026
- andypitcher/ponytail-sectheir own version, first seen Nov 7, 2026
- StephanMeijer/skillstheir own version, first seen Nov 6, 2026
- YKDZ/skillstheir own version, first seen Nov 1, 2026
- infiniumtek/code-review-agenttheir own version, first seen Oct 25, 2026
- Jinbae10/skillstheir own version, first seen Jul 7, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- andypitcher/ponytail-sec★ 12same name
- infiniumtek/code-review-agent★ 4same name
- YKDZ/skills★ 2same name
- brpaz/agent-skills★ 1same name
- petr-korobeinikov/skills★ 1same name
- CorentinGC/claude-skills★ 0same name
- Jinbae10/skills★ 0same name
- StephanMeijer/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository124 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/AGENTS.mdAGENTS.md
- .github/workflows/AGENTS.mdAGENTS.md
- .vscode/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- agent-log-analysisSkill
- agent-mdSkill
- agent-md-writerSkill
- agent-skill-md-writerSkill
- agentskillsSkill
- agents-md-writerSkill
- ai-prompt-writerSkill
- ansibleSkill
- apache-airflow-apiSkill
- apache-airflow-dagsSkill
- astro-cliSkill
- astronomer-docsSkill
- awesome-copilotSkill
- brainstorm-agent-runsSkill
- brainstorm-github-prSkill
- brainstormSkill
- catSkill
- chrome-devtoolsSkill
- claude-docsSkill
- codeqlSkill
- code-reviewSkill
- code-tourSkill
- coding-standard-writerSkill
- context-aware-opsSkill
- copilot-cliSkill
- copilot-docsSkill
- critical-thinkingSkill
- datadog-agentSkill
- datadog-apiSkill
- datadog-mcpSkill
- datadog-monitorsSkill
- datadog-pulumiSkill
- devcontainerSkill
- dictationSkill
- direnvSkill
- dockerSkill
- docs-reviewSkill
- docs-writerSkill
- dot-claudeSkill
- dotfilesSkill
- dot-githubSkill
- editorconfigSkill
- fact-writerSkill
- gdpr-compliantSkill
- gh-agent-taskSkill
- gh-apiSkill
- gh-aw-compileSkill
- gh-aw-firewall-debugSkill
- gh-aw-firewallSkill
- gh-aw-newSkill
- gh-awSkill
- gh-aw-troubleshootingSkill
- gh-codespaceSkill
- gh-issueSkill
- gh-modelsSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 3 are distinctive, and 12 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Create and maintain highly optimized, secure, and minimal Dockerfiles.
- Very specific: line 15
When writing, optimizing, or reviewing a Dockerfile for a new or existing service.
- Very specific: line 17
When auditing a Dockerfile for security compliance (e.g., non-root users, pinned bases).
- Very specific: line 21
When configuring local development environments that rely strictly on devcontainer.json without custom Dockerfiles.
- Distinctive: line 23
If the project relies on Cloud Native Buildpacks (CNB) rather than explicit Dockerfiles.
- Very specific: line 33
Base Selection: Use official, minimal bases (e.g., alpine, distroless) with precise version tags or SHA256 pinning.
- Very specific: line 41
Determinism: Avoid latest tags to prevent build drift and ensure reproducible environments.
- Distinctive: line 42
Immutability: Treat the container filesystem as read-only.
- Very specific: line 43
Signal Handling: Use the exec JSON array form for ENTRYPOINT and CMD (e.g., ["node", "app.js"]) instead of shell form to allow graceful …
- Very specific: line 76
Use gh search to surface advanced Dockerfile patterns and community best practices directly from GitHub:
- Very specific: line 85
Cache Misses: Ensure COPY . . is positioned as late as possible.
- Very specific: line 90
Avoid Root: Never omit the USER directive in a production image.
- Very specific: line 91
Avoid Shell Form: Do not write ENTRYPOINT npm start.
- Very specific: line 92
Avoid Build Tools in Runtime: Never ship gcc, make, or similar tools in the final image.
- Very specific: line 93
Avoid Baked Secrets: Never embed credentials using ENV or COPY.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: dockerfile
<!-- markdownlint-disable MD013 MD023 MD031 MD032 -->Create and maintain highly optimized, secure, and minimal Dockerfiles. Focus on strict deterministic builds, security compliance, and caching efficiency.
When to Use
- When writing, optimizing, or reviewing a
Dockerfilefor a new or existing service. - To reduce the image size or improve the layer caching efficiency of an existing Docker build.
- When auditing a
Dockerfilefor security compliance (e.g., non-root users, pinned bases).
When Not to Use
- When configuring local development environments that rely strictly on
devcontainer.jsonwithout custom Dockerfiles. - For managing runtime container orchestration (use
dockerordocker-composeinstead). - If the project relies on Cloud Native Buildpacks (CNB) rather than explicit Dockerfiles.
Common Pitfalls
- Leaking Secrets: Using
COPYorENVto handle build secrets instead of the secure--mount=type=secretdirective. - Late User Switching: Defining
USER nonrootbut forgetting tochownthe files copied from the builder stage, leading to permission denied errors at runtime. - Cache Busting: Placing rapidly changing instructions (like
COPY . .) before slow, static instructions (likenpm install), destroying layer cache efficiency on every code change.
Core Process
- Base Selection: Use official, minimal bases (e.g.,
alpine,distroless) with precise version tags or SHA256 pinning. - Dependency Layering: Copy manifests (e.g.,
package.json,go.mod) first, install dependencies, thenCOPYsource code to maximize cache hits. - Multi-Stage Builds: Separate build-time environments from runtime execution. Only copy compiled artifacts to the final stage.
- Layer Consolidation: Chain
RUNcommands with&&and clear package manager caches within the same layer. - Least Privilege: Define a non-root
USERbeforeENTRYPOINTorCMD.
Core Principles
- Determinism: Avoid
latesttags to prevent build drift and ensure reproducible environments. - Immutability: Treat the container filesystem as read-only. Mount volumes for mutable paths.
- Signal Handling: Use the
execJSON array form forENTRYPOINTandCMD(e.g.,["node", "app.js"]) instead of shell form to allow graceful termination (SIGTERM).
Commands / Usage Patterns
- Minimal Multi-Stage Pattern:
# Use specific version and digest for deterministic builds FROM golang:1.24.0-alpine3.21@sha256:e74d913cc537f546b946e685c84a98598ba93b4de1f762d0c353a4261a1d1052 AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . # Force static build by disabling CGO and stripping symbols RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /server . # Use a digest-pinned nonroot distroless base for maximum security FROM gcr.io/distroless/static-debian12:nonroot@sha256:e906328329624536768a49c9527ec3c3068e14e1a0b3554e2043697e88457e5e COPY --from=builder /server /server USER nonroot:nonroot EXPOSE 8080 ENTRYPOINT ["/server"] - Deterministic Package Installation:
RUN apt-get update && \ apt-get install -y --no-install-recommends \ curl=7.88.1-10+deb12u8 \ jq=1.6-2.1 && \ rm -rf /var/lib/apt/lists/* - Discovering Real-World Usage:
Use
gh searchto surface advanced Dockerfile patterns and community best practices directly from GitHub:- Find multi-stage architecture examples (requires
ASkeyword):gh search code "FROM" "AS" --language dockerfile --limit 5 --json repository,path,url - Locate repository templates and guides (sorted by stars):
gh search repos "Dockerfile best practices" --sort stars --order desc --limit 5 --json fullName,description,url
- Find multi-stage architecture examples (requires
Diagnostics and Troubleshooting
- Large Images: Inspect layer bloat with
docker history <image>or usedive. Watch for orphaned cache files. - Cache Misses: Ensure
COPY . .is positioned as late as possible. A single modified source file busts the cache for all subsequent steps. - Permission Denied: If a non-root user fails to execute, verify ownership of
WORKDIR, copied artifacts, and runtime directories. Crucial: Ownership must be fixed in the final image stage (e.g., usingCOPY --chownorRUN chownbefore switching toUSER), as permissions set in builder stages do not persist for files copied to the final runtime image. Distroless images may require fixing ownership in the builder if the final image lacks shell tools, or ideally usingCOPY --chown.
What to Avoid
- Avoid Root: Never omit the
USERdirective in a production image. - Avoid Shell Form: Do not write
ENTRYPOINT npm start. Using shell form spawns a/bin/shwrapper, breaking signal propagation. - Avoid Build Tools in Runtime: Never ship
gcc,make, or similar tools in the final image. - Avoid Baked Secrets: Never embed credentials using
ENVorCOPY. Use--mount=type=secretduring build or inject at runtime.
Related Skills
- docker: You MUST load this skill when running, managing, or troubleshooting Docker containers and networks.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

