Claude-prime docker
ALWAYS activate when the user's query involves Docker in any way — even if it also matches other skills. If the words docker, Dockerfile, docker-compose, compose.yml, container, or image appear in the query, this skill MUST be used. Covers: writing or editing Dockerfiles and compose files, adding services (postgres, redis, etc.) to compose, volume mounts and data persistence, docker build failures (layer caching, npm install issues), healthchecks and service startup ordering (depends_on), environment variables in containers, port mapping, container crashes and exit codes (OOM/137), non-root users, multi-stage builds, image optimization, .dockerignore, and deploying to container runtimes. Takes priority over general implementation or debugging skills when Docker infrastructure is the subject.
git clone https://github.com/avibebuilder/claude-prime
T=$(mktemp -d) && git clone --depth=1 https://github.com/avibebuilder/claude-prime "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/starter-skills/docker" ~/.claude/skills/avibebuilder-claude-prime-docker && rm -rf "$T"
.claude/starter-skills/docker/SKILL.mdDocker
Project-specific containerization patterns for Dockerfile and Docker Compose.
Architecture Decisions
Image Building
- Minimal base images — Use slim/alpine variants; pin to digest for reproducibility.
- Multi-stage builds — Separate build dependencies from runtime.
- Layer optimization — Combine RUN commands; place frequently changed files last.
- COPY over ADD — ADD only for tar extraction or remote URLs.
Security
- Non-root users — Always use UID >10000; never run as root in production.
- No secrets in images — Use Docker secrets or runtime env injection.
- .dockerignore required — Exclude .git, .env, node_modules, build artifacts.
Runtime
- One process per container — Single responsibility principle.
- Healthchecks required — Define HEALTHCHECK in Dockerfile or Compose.
- Resource limits — Always set mem_limit and cpus in production.
Compose
- Network segmentation — Dedicated networks per service group.
- Named volumes — Never use anonymous volumes in production.
- depends_on with healthchecks — Use
.condition: service_healthy - Environment separation — Use override files for dev/staging/prod.
Gotchas
beforeCOPY . .
busts the cache on EVERY code change. CopyRUN npm install
first, install, THEN copy source.package*.json- Alpine uses musl libc, not glibc. Python packages with C extensions (numpy, pandas, cryptography) may fail to install or need
build dependencies. Considerapk add
variants if you hit this.-slim
(exec form) handles signals correctly.ENTRYPOINT ["python", "app.py"]
(shell form) wraps inENTRYPOINT python app.py
and PID 1 won't receive SIGTERM — containers take 10s to stop./bin/sh -c- Docker layer cache is invalidated from the FIRST changed layer downward. A changed
near the top rebuilds everything below it.COPY
withoutdepends_on
only waits for container START, not readiness. Your app will crash connecting to a database that's still initializing.condition: service_healthy
works on Docker Desktop (Mac/Windows) but NOT on Linux. Usehost.docker.internal
or explicit container networking on Linux.--network host- Build args (
) are NOT available afterARG
in multi-stage builds unless re-declared. Each stage starts fresh.FROM
reuses existing containers. After changingdocker compose up
, you needDockerfile
ordocker compose up --build
first.docker compose build- Volume mounts override the container's filesystem — if your
are built inside the container but you mountnode_modules
, the host's (possibly empty).:/app
shadows them. Use a named volume fornode_modules
.node_modules
is documentation only — it does NOT publish the port. You still needEXPOSE
or-p 8080:8080
in compose.ports:- Docker's default bridge network does NOT provide DNS resolution between containers. Use a custom network or compose's default network.
References
| When you need... | Read |
|---|---|
| Dockerfile patterns, CMD vs ENTRYPOINT | dockerfile.md |
| Compose services, networks, volumes | compose.md |
| Security hardening | security.md |
| Production deployment | production.md |