CONTAINERS / Docker
Docker Build Strategies
Teaches Docker BuildKit multi-stage builds, target execution, cache mount typing, and minimal distroless runtime patterns.
“Use this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization.”
01 / THE REASONING
Why this made the selection.
- Prescribes explicit BuildKit cache mounts (--mount=type=cache,target=/root/.cache) and discrete build targets instead of invalidating entire layers on unrelated changes.
- Demands rigorous .dockerignore verification and least-privilege non-root execution inside runtime stages to minimize attack surfaces.
02 / THE REVIEW RECORD
What we actually inspected.
Source review has boundaries.
A clear record is more useful than a “safe” badge.
Material inspected
- skills/docker-build-strategies/SKILL.md
- LICENSE
- skills/docker-build-strategies/scripts/verify-build.sh
Our findings
- The Apache appendix explicitly declares Copyright 2026 Docker, Inc.
- BuildKit cache mounts are segregated by target package manager (/root/.cache/pip, /root/.cache/go-build) avoiding cache poisoning across build stages.
- Inspected helper builds the current directory, then calls docker images and docker inspect; no application health test is included.
- Guidance requires numeric UID:GID with COPY --link --chown and distinguishes optional from required secret mounts.
- The pinned skill requires a syntax directive, named stages, dependency manifests before source, and a non-root user in the final image.
Not established by this review
- Docker build executions and container runs were not performed in this session.
- The references/multi-stage-builds.md and references/layer-caching.md subdocuments were not verified line-by-line.
- Not executed: it was not installed or run.
The review applies to the material and revision named here. A newer upstream release can change its behavior.
03 / PUT IT TO WORK
Add a skill to your workflow.
DOCUMENTED COMMAND
npx skills add docker/skills/skills/docker-build-strategies Run in your terminal to choose your AI tools, project or global scope, and installation method. This short command follows the current upstream version; the review covers the revision shown above.
Optional: install the reviewed revision
Keeps the original source and installer version where recorded, while leaving your AI tools and installation scope for you to choose.
npx skills add https://github.com/docker/skills/tree/f79172733725e2fd236343ee7b963c446ed85d09/skills/docker-build-strategies - Run the pinned npx skills add command targeting only the docker-build-strategies directory.
- Do not install the root docker/skills repository unless all contained skills are explicitly desired.
Before you start
- Node.js runtime for the npx installer
- Docker CLI and BuildKit-enabled daemon
04 / FOLLOW THE EVIDENCE
The source trail.
Our notes are separate from the original resource.
Check upstream before adopting a new version.
https://github.com/docker/skills/blob/f79172733725e2fd236343ee7b963c446ed85d09/skills/docker-build-strategies/SKILL.md
Supports: summary, whySelected, bestFor, limitations
https://github.com/docker/skills/blob/f79172733725e2fd236343ee7b963c446ed85d09/LICENSE
Supports: license
https://github.com/docker/skills/blob/f79172733725e2fd236343ee7b963c446ed85d09/skills/docker-build-strategies/scripts/verify-build.sh
Supports: review, limitations, access, install
https://raw.githubusercontent.com/docker/skills/f79172733725e2fd236343ee7b963c446ed85d09/skills/docker-build-strategies/SKILL.md
Supports: upstreamDescription, review.notTested, review.reviewedAt