/docker:dockerfrom docker
Writes and reviews Dockerfiles, Compose files and .dockerignore: multi-stage builds, layer caching, non-root runtime, daemon.json hardening, secrets and container debugging. Use when creating or changing a Dockerfile, compose.yaml or daemon.json, hardening an image or host, or debugging a container that won't build, start or connect.
Ships in docker. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Not for Kubernetes manifests (the kubernetes skill), Helm charts (helm), CI workflow authoring (gh-actions), or rollout planning (rollout-plan).
Change Dockerfiles and Compose files from what the repo already builds and runs. Match its base images, package manager, and service names before applying the rules below.
Dockerfile*, compose*.yaml, .dockerignore, and the lockfile or build manifest the image installs from.build.target.deps, build, test (optional), runtime. Each stage is named with AS so Compose and CI can target it.package.json and the lockfile, run npm ci, and only then COPY . ..:latest. Pin by digest for release builds so rebuilds are reproducible. Refresh pins on a schedule, since a pin that never moves stops getting security fixes.COPY --from=build. Build tools, compilers, and test dependencies stay in earlier stages. Distroless images have no shell, so use exec-form commands and a healthcheck that does not need sh or wget.nonroot tag) and set USER before CMD. Use COPY --chown so files are owned correctly without an extra layer.CMD and ENTRYPOINT (["node", "dist/server.js"]). Shell form wraps the process in sh -c, so SIGTERM never reaches the app and shutdown waits for the kill timeout.HEALTHCHECK for long-running services that Compose or a plain Docker host supervises. Kubernetes ignores it and uses its own probes (the kubernetes skill).NODE_ENV=production and similar runtime flags in the runtime stage only.RUN steps that must share a cache lifetime, such as apt-get update && apt-get install -y --no-install-recommends ... && rm -rf /var/lib/apt/lists/*. Don't merge unrelated steps, because one change then invalidates all of them.The build context is everything not ignored, so it decides what COPY . . can bake into a layer. Start from this and extend it for the project:
.git
.env
.env.*
secrets/
*.pem
*.key
node_modules
dist
coverage
*.log
.env and .env.* always. A COPY . . with no .dockerignore copies the file into the image, where anyone who pulls the image can extract it.secrets: sources, keys, certificates) out of the build context, or ignore them as above. A COPY . . stage bakes in whatever the context holds. Rename the secrets/ pattern if the project keeps them elsewhere..dockerignore at the context root, or use <Dockerfile name>.dockerignore beside a specific Dockerfile. The more specific file wins.COPY needs. A ! line re-includes a path, and the last matching line decides.Accepted ways to give a container a secret at runtime:
| Method | Notes |
|---|---|
Gitignored .env via env_file: | Not baked into the image. Never commit it, and keep it in .dockerignore. |
Host environment passthrough (environment: [API_KEY]) | Compose reads the value from the shell that runs it. |
Compose secrets: with a file: or environment: source | Mounted as a file at /run/secrets/<name> in only the services that list it. Works without Swarm on Linux containers. |
Know the limits before choosing:
docker inspect and inside the container through the process environment, and child processes inherit them. Prefer file-mounted secrets (secrets:) for sensitive values such as database passwords and API keys.ENV persist in image layers. For a secret needed during the build, use RUN --mount=type=secret,id=<name> with docker build --secret id=<name>,src=<path>. The secret is available at /run/secrets/<name> only for that step.<placeholder> values in examples.docker inspect or docker compose config output wholesale into a transcript, since both can expand secret values from the environment.Read compose before writing or restructuring a Compose file. The rules that matter most:
depends_on and condition: service_healthy, backed by a real healthcheck on the dependency. Plain depends_on waits only for the container to start."127.0.0.1:5432:5432") and omit ports for services reachable only from other services.down, and bind mounts only for dev source code.compose.override.yaml (auto-loaded) and production settings in a file selected with -f.docker compose config --quiet after every edit.Compose suits a single host. When a workload needs several hosts, rolling updates, or self-healing, use an orchestrator (the kubernetes skill).
For production services, add what the app can tolerate and test the app after each addition:
services:
app:
read_only: true
tmpfs: [/tmp]
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
read_only needs tmpfs or a volume for every path the app writes. A startup crash on a write is the signal to add one.cap_drop: [ALL] then cap_add only what is needed, such as NET_BIND_SERVICE for ports below 1024.-p 8080:80) binds all host addresses, and Docker routes its traffic before ufw's rules apply, so a ufw deny does not close it. Bind to loopback (127.0.0.1:8080:80) unless the service must be reachable from outside./etc/docker/daemon.json, socket, remote API, rootless mode, CIS section 2), read daemon hardening.Start read-only and escalate only when needed.
docker compose ps
docker compose logs --tail=100 <service>
docker compose config --quiet # validates and resolves the file
docker inspect --format '{{.State.ExitCode}} {{.State.OOMKilled}}' <container>
docker stats --no-stream
See debugging for build failures, networking and DNS, volume permission errors, and exit codes. These need the user's approval first because they change or delete state: docker compose down -v and --remove-orphans, docker volume rm and prune, docker image prune -a, docker system prune, docker rm, and docker compose up --build on shared hosts.
.dockerignore excludes .git, .env*, and build output.USER is non-root; CMD is exec form.ENV, ARG, a layer, or a committed Compose file.depends_on or restart logic relies on them.docker compose config --quiet and docker build both succeed.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin docker