Claude-skill-registry docker-architect
SOTA Docker/Compose architecture, implementation, refactor, and security hardening. Use when working on containerization tasks such as creating or rewriting Dockerfiles, docker-compose files, buildx/bake configs, .dockerignore, and CI pipelines for build/test/scan/publish; auditing existing container setups for security, correctness, size/perf, and best practices (least privilege, non-root, minimal images, pinned base images, BuildKit secrets, healthchecks); debugging Docker build/run issues; or designing dev vs prod compose workflows across services (DB/cache/queues) with correct networking, volumes, secrets, and resource limits.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/docker-architect" ~/.claude/skills/majiayu000-claude-skill-registry-docker-architect && rm -rf "$T"
skills/data/docker-architect/SKILL.mdDocker Architect
Overview
Produce production-grade, secure, right-sized Docker images and Compose environments end-to-end: inventory → design → implement → test → CI. Prefer minimal, reproducible builds (multi-stage + BuildKit) and least-privilege runtime defaults.
Quick Start (always do this first)
- Inventory the repo and existing container config:
- Run
python3 /home/bjorn/.codex/skills/docker-architect/scripts/docker_inventory.py --root .
- Run
- Choose the target:
- New containerization → follow “New build workflow”
- Existing Dockerfiles/Compose → follow “Audit + refactor workflow”
- Validate locally:
docker buildx version
(ordocker buildx build ...
)docker build ...
anddocker compose configdocker compose up --build
Template rendering example (edit variables per repo):
python3 /home/bjorn/.codex/skills/docker-architect/scripts/render_template.py --template .dockerignore --out .dockerignorepython3 /home/bjorn/.codex/skills/docker-architect/scripts/render_template.py --template compose/docker-compose.yml --out docker-compose.yml --var IMAGE_NAME=myapp:dev --var HOST_PORT=8000 --var CONTAINER_PORT=8000python3 /home/bjorn/.codex/skills/docker-architect/scripts/render_template.py --template compose/docker-compose.dev.yml --out docker-compose.dev.yml --var CONTAINER_PORT=8000 --var DEV_COMMAND='[\"python\",\"-m\",\"uvicorn\",\"myapp.api:app\",\"--host\",\"0.0.0.0\",\"--port\",\"8000\",\"--reload\"]'
Workflow Decision Tree
- Scope:
- Dev-only (fast iteration, source mounts, hot reload) → prefer
docker-compose.dev.yml - Prod-like (immutable images, healthchecks, least privilege) → prefer
+docker-compose.ymldocker-compose.prod.yml
- Dev-only (fast iteration, source mounts, hot reload) → prefer
- Artifact type:
- Single service → one Dockerfile + optional compose for deps
- Multi-service → compose with explicit networks/volumes and healthchecks
- Publish target:
- Local only → keep simple; optional CI smoke checks
- Registry publish → add CI build/test/scan/push + provenance/SBOM (if available)
New build workflow (Dockerfile + .dockerignore + compose)
- Pick a base strategy (see
):references/dockerfile_patterns.md- Multi-stage build; runtime image is minimal; build tools stay in builder stage.
- Prefer slim/distroless where feasible; default to non-root user.
- Add
early (template in.dockerignore
).assets/templates/.dockerignore - Create a Dockerfile from templates:
- Prefer
for modern Python/assets/templates/python/Dockerfile.uvuv - Prefer
for Node + pnpmassets/templates/node/Dockerfile.pnpm - Use
to render with variables.python3 /home/bjorn/.codex/skills/docker-architect/scripts/render_template.py ...
- Prefer
- Add a compose file for dependencies (DB/cache) and dev/prod profiles:
- Start from
+ an override (assets/templates/compose/docker-compose.yml
orassets/templates/compose/docker-compose.dev.yml
)assets/templates/compose/docker-compose.prod.yml - Optional deps file:
assets/templates/compose/docker-compose.deps.yml
- Start from
- Local validation:
bash /home/bjorn/.codex/skills/docker-architect/scripts/smoke_test_container.sh --help- Optional:
(Docker build checks) and--build-check
(fresh base images)--pull - For compose:
bash /home/bjorn/.codex/skills/docker-architect/scripts/smoke_test_compose.sh --help
Audit + refactor workflow (existing Dockerfiles/Compose)
- Inventory + static audit:
python3 /home/bjorn/.codex/skills/docker-architect/scripts/docker_audit.py --root .
- Identify high-risk issues (see
):references/security_hardening.md- Secrets in image/build args, root/privileged runtime, overly broad mounts, host networking, “latest” tags, missing healthchecks.
- Refactor incrementally:
- Keep behavior stable, then tighten (non-root, read-only fs, drop caps, pin images, shrink layers).
- Validate end-to-end:
docker buildx build ...
and run the app’s normal test/health commands.docker compose up --build
- Produce a concise report (template in
).references/review_template.md
CI integration workflow (GitHub Actions default)
- Start from
.assets/templates/ci/github-actions-docker-ci.yml- For publish + SBOM/provenance to GHCR:
assets/templates/ci/github-actions-docker-publish.yml
- For publish + SBOM/provenance to GHCR:
- Ensure CI runs:
(cache enabled)docker buildx build
(compose validation)docker compose config- optional: build checks (
) and scan/SBOM/provenance stepsdocker build --check
- Prefer pinned action versions and least-privilege permissions (see
).references/ci_github_actions.md
“Latest/correct” research rule (do not guess)
When “latest” matters (base images, distro versions, language runtimes, CVEs):
- Use Exa to confirm current official guidance and tags (official sources preferred).
- Use
to confirm manifests/platforms.docker buildx imagetools inspect <image:tag> - If unsure, mark as
and propose a safe default with a verification step.UNVERIFIED
Tooling leverage (when it helps)
- Exa: find current best practices, base image changes, CVE guidance, GitHub Actions deprecations.
- Context7: confirm framework-specific build outputs (e.g., Next.js, FastAPI, uvicorn/gunicorn, etc.).
- Zen: use
for a structured container/security audit andzen.secaudit
for architecture-sensitive compose design.zen.analyze - gh_grep: search public repos for battle-tested patterns (entrypoints, healthchecks, buildx/bake, compose profiles).
- opensrc: inspect dependency internals when container behavior depends on packaging details.
Bundled resources
Scripts
: detect stack + existing Docker/Compose files.scripts/docker_inventory.py
: heuristic linting of Dockerfiles/Compose for security/correctness.scripts/docker_audit.py
: render templates withscripts/render_template.py
into repo files.{{VARS}}
: build/run basic health check locally.scripts/smoke_test_container.sh
: validate + bring up compose and check health.scripts/smoke_test_compose.sh
References (load as needed)
: BuildKit, caching, multi-stage, runtime hardening.references/dockerfile_patterns.md
: compose patterns, profiles, healthchecks, secrets/configs.references/compose_patterns.md
: least privilege, capabilities, read-only fs, supply chain.references/security_hardening.md
: CI build/test/scan/publish patterns.references/ci_github_actions.md
: audit report format and deliverables checklist.references/review_template.md
Assets (templates)
Templates live under
assets/templates/ (Dockerfile variants, compose variants, CI workflow, .dockerignore, docker-bake.hcl).