docker-best-practices
Skill1 starsChanged 9 days agoMITView on GitHub
Write, review, and harden Dockerfiles and docker-compose setups for small, fast, secure images. Use whenever the user shares a Dockerfile or compose file, asks to containerize an app, reduce image size, speed up builds, or fix container security or caching problems.
- Reads credentials
- Deletes or force-pushes
- Installs packages
5 other projects use a version of this.
Adopted by
Most recently taken up by
- baekenough/oh-my-customcodetheir own version, first seen Nov 23, 2026
- Wade-DevCode/awesome-coding-skills-cntheir own version, first seen Nov 8, 2026
- Spardutti/claude-skillstheir own version, first seen Aug 31, 2026
- Nadav011/apex-skillstheir own version, first seen Apr 22, 2026
- hieutrtr/ai1-skillstheir own version, first seen Feb 5, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- baekenough/oh-my-customcode★ 47same name
- hieutrtr/ai1-skills★ 8same name
- Wade-DevCode/awesome-coding-skills-cn★ 7same name
- Spardutti/claude-skills★ 3same name
- Nadav011/apex-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 repository26 other files it gives its agents.
- adr-writerSkill
- api-design-reviewSkill
- changelog-generatorSkill
- chart-selectorSkill
- code-reviewSkill
- commit-and-pr-writerSkill
- csv-profilerSkill
- debugging-playbookSkill
- email-drafterSkill
- executive-summarySkill
- incident-postmortemSkill
- meeting-actionsSkill
- okr-writerSkill
- plain-language-editorSkill
- prd-writerSkill
- pre-push-secret-scanSkill
- prompt-improverSkill
- readme-writerSkill
- refactoring-guideSkill
- resume-tailorSkill
- security-reviewSkill
- source-evaluatorSkill
- sql-optimizerSkill
- study-plan-builderSkill
- test-writerSkill
- my-skill-nameSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 2 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Run as non-root: create a user and USER app.
- Distinctive: line 19
Add a HEALTHCHECK where the platform does not provide one.
- Very specific: line 20
Prefer COPY over ADD. Set WORKDIR explicitly.
- Distinctive: line 24
Do not publish ports that only other containers need.
- Very specific: line 25
Use named volumes for data, and depends_on with health conditions.
- Very specific: line 26
Keep secrets out of the compose file.
“Common” is measured: kept by at least 6 in 10 of the 3 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
Docker Best Practices
Dockerfile checklist
- Pin the base image to a specific version (ideally a digest for production). Never rely on
latest. - Use small, appropriate bases:
-slim, distroless, or alpine (beware musl incompatibilities with some Python/Node native packages). - Multi-stage builds: compile or install dev dependencies in a builder stage, copy only artifacts into the final stage.
- Order layers for cache: copy dependency manifests (
requirements.txt,package*.json) and install first, then copy source. - Combine and clean:
apt-get update && apt-get install -y --no-install-recommends ... && rm -rf /var/lib/apt/lists/*in one RUN. - Run as non-root: create a user and
USER app. - Use
.dockerignoreto exclude.git,node_modules,.env, build output, tests. - Never bake secrets into layers (ARG/ENV/COPY). Use runtime env vars, orchestrator secrets, or BuildKit
--mount=type=secret. - Exec-form CMD/ENTRYPOINT (
["python","app.py"]) so signals reach the process; considertini/--init. - Add a HEALTHCHECK where the platform does not provide one.
- Prefer
COPYoverADD. SetWORKDIRexplicitly.
Compose checklist
- Do not publish ports that only other containers need.
- Use named volumes for data, and
depends_onwith health conditions. - Keep secrets out of the compose file; use
.env(git-ignored) or secrets. - Set resource limits and
restartpolicy where relevant. - Separate dev overrides (
compose.override.yml) from production config.
Output
Return a corrected Dockerfile with inline comments on each change, a .dockerignore if missing, and a brief list of remaining risks (image scanning with Trivy/Grype, SBOM, update cadence). Estimate size or build-time impact only when you can justify it.
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.

