docker-discipline
Skill4 starsChanged 9 months agoUnlicenseView on GitHub
Use whenever creating or modifying Dockerfiles, compose files, or deployment configs — any change to how a project builds or runs in containers. This is the discipline skill — for Docker behavior lookups and troubleshooting, use docker instead.
- Reads credentials
In this repository70 other files it gives its agents.
- agent/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- git-guardrails-claude-codeSkill
- setup-project-skillsSkill
- skill-creatorSkill
- websearchSkill
- writing-great-skillsSkill
- codebase-designSkill
- construction-craftSkill
- critical-partnerSkill
- data-intensiveSkill
- diagnosing-bugsSkill
- django-disciplineSkill
- documentation-lifecycleSkill
- domain-driven-designSkill
- enterprise-patternsSkill
- git-disciplineSkill
- legacy-codeSkill
- production-readinessSkill
- refactoring-passSkill
- resolving-merge-conflictsSkill
- tddSkill
- testing-workflowSkill
- ui-design-directionSkill
- webapp-testingSkill
- django-allauthSkill
- djangoSkill
- dockerSkill
- drfSkill
- full-calendarSkill
- giteaSkill
- htmxSkill
- http-status-codesSkill
- hyperscriptSkill
- langchainSkill
- litestarSkill
- prestashopSkill
- pykeSkill
- python-asyncSkill
- tablerSkill
- cleanroom-rewriteSkill
- councilSkill
- court-jesterSkill
- domain-modelingSkill
- fix-prSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- humanifySkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- ponytail-auditSkill
- ponytail-debtSkill
- prototypeSkill
- qaSkill
- researchSkill
- restore-test-pyramidSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
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
- Distinctive: line 38
Keep build dependencies out of the runtime image: build in one stage, copy the artifacts into a slim runtime stage that runs as the …
- Very specific: line 55
Create .dockerignore before building anything.
- Very specific: line 81
Create a standalone compose file passed with -f instead of relying on override merge
- Very specific: line 92
Test infrastructure MUST use a separate compose.test.yml — profiles do NOT provide lifecycle independence.
- Very specific: line 139
Use profiles for configuration variants within one stack.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docker Discipline
Rules for authoring Docker configs. Every rule traces to a real production issue.
For how Docker itself behaves (networking, storage, BuildKit, registries,
diagnosis), load the docker skill — it owns reference and troubleshooting.
Dockerfile Rules
Non-Root User, UID-Matched (Critical)
Match the container user's UID to the host user to avoid bind-mount permission issues.
# ✅ Correct: Match host UID
ARG HOST_UID=1000
RUN groupadd -g ${HOST_UID} app && \
useradd -u ${HOST_UID} -g app -m app
USER app
# ❌ Forbidden: Hardcoded root or mismatched UID
USER 1001 # Won't match host, causes permission errorsPlace the USER directive AFTER all RUN/COPY commands in the Dockerfile.
Multi-Stage Builds
Keep build dependencies out of the runtime image: build in one stage, copy the artifacts into a slim runtime stage that runs as the non-root user above.
Secrets Never in ARG or ENV
ARG and ENV values persist in image history and layer metadata. Pass
build-time secrets with BuildKit mounts instead:
RUN --mount=type=secret,id=pypi_token uv sync --frozenBuild with docker build --secret id=pypi_token,src=...; use --ssh with
RUN --mount=type=ssh for private git dependencies.
.dockerignore Before the First Build
Create .dockerignore before building anything. Oversized or accidental build
contexts slow builds, break layer caches, and leak secrets (.env, .git,
local artifacts) into images.
Docker Compose Rules
Port Arrays Merge, They Don't Replace
In docker-compose.override.yml, a ports: list is appended to the base file's list — not replaced.
# base compose.yml
services:
web:
ports:
- "8000:8000"
# override (this ADDS port 8001, doesn't replace 8000)
services:
web:
ports:
- "8001:8000"To change a port binding, either:
- Edit the base file directly
- Create a standalone compose file passed with
-finstead of relying on override merge
Readiness Is Explicit
depends_on short syntax only orders startup — it says nothing about the
dependency being ready. When readiness matters, give the dependency a
healthcheck and depend with condition: service_healthy (see the test compose
below for the full pattern).
Test Infrastructure: Separate Compose File
Test infrastructure MUST use a separate compose.test.yml — profiles do NOT provide lifecycle independence.
# compose.test.yml
services:
testdb:
image: postgres:16
environment:
POSTGRES_DB: test_db
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U test_user -d test_db"]
interval: 2s
timeout: 5s
retries: 10
networks:
- test-net
# NO ports — intentionally not exposed
tests:
build:
context: .
dockerfile: Dockerfile.test
depends_on:
testdb:
condition: service_healthy
environment:
DATABASE_URL: postgresql://test_user:test_password@testdb:5432/test_db
volumes:
- .:/app
networks:
- test-net
# NO ports — intentionally not exposed
networks:
test-net:
driver: bridgeLifecycle Independence
docker compose down(dev) MUST NOT affect testsdocker compose -f compose.test.yml down(tests) MUST NOT affect dev
Profiles for Variants, Files for Lifecycles
Use profiles for configuration variants within one stack. Exception: test
infrastructure MUST use a separate compose.test.yml (above) — profiles do not
give it an independent lifecycle.
References
- Gotchas & Practical Guidance — Common pitfalls: bind mounts overriding build artifacts,
uv runimplicit sync, volume mount ordering, non-root UID mismatch, healthcheck timing, network namespace confusion, build cache invalidation, environment variable precedence.
Task Routing
- Dockerfile structure, non-root user, secrets, multi-stage -> This SKILL.md (main content)
- Build cache optimization, COPY ordering ->
references/gotchas.md(Build Cache Invalidation section) - Volume mount issues, bind mount overrides ->
references/gotchas.md(Bind Mounts Override Build Artifacts section) uv runbehavior, implicit sync ->references/gotchas.md(uv run Does Implicit Sync section)- Healthcheck configuration, depends_on ->
references/gotchas.md(Healthcheck Timing section) - Network configuration, service communication ->
references/gotchas.md(Network Namespace Confusion section) - Environment variables, env_file vs environment ->
references/gotchas.md(Environment Variable Precedence section) - Volume mount ordering, named vs bind mounts ->
references/gotchas.md(Volume Mount Ordering section) - How Docker behaves, troubleshooting, boundary questions -> load the
dockerskill
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.

