[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EMXY5VHF2VZB7ZYD7BTP6J":3,"skill-same:01M7EMXY5VHF2VZB7ZYD7BTP6J":90},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7EMXY5VHF2VZB7ZYD7BTP6J","docker-build-strategies",null,"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.","Rainbow609\u002Fagent-skills","Rainbow609","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F101709481?v=4","01M7EMQ6CNBNP7TVFZ4Z63RZXD","01M7EMQ6ENV4B0Y542WKXNZBSM",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: docker-build-strategies\ndescription: 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.\nlicense: Apache-2.0\ncompatibility: Requires Docker 23.0+ (BuildKit default). On Docker 20.10–22.x, set DOCKER_BUILDKIT=1 before building.\n---\n\n# Docker Build Strategies\n\n## Overview\n\nThis skill provides rules and patterns for writing and reviewing production-quality Dockerfiles. Apply it when the main task is image-build quality: multi-stage builds, cache behavior, non-root execution, build context hygiene, and runtime image size.\n\n## When to use this skill\n\nActivate this skill when:\n\n- Creating a new Dockerfile for any language or framework\n- Optimizing an existing Dockerfile for size, speed, or security\n- Reviewing a Dockerfile for best-practice compliance\n- Adding a `.dockerignore` file to a project\n\n## Do not use this skill when\n\nDo not use this skill when:\n\n- The project has no Docker setup yet and the main need is a first-pass scaffold\n- The main task is wiring services together in `compose.yaml`\n- The main task is debugging Compose startup ordering, networking, or development overrides\n\n## Core guidance\n\n### Multi-stage builds\n\nUse multi-stage builds when the project has a build step or when build-time dependencies differ from runtime. Separate build-time dependencies from the runtime image.\n\n1. Name every stage explicitly (`FROM ... AS build`, `FROM ... AS runtime`).\n2. Use the smallest appropriate base for the runtime stage: `distroless`, `alpine`, or `slim` variants.\n3. Copy only the final artifact into the runtime stage with `COPY --from=build`.\n4. Use `COPY --link` when copying from a prior stage or adding static files — it improves cache reuse by making the COPY independent of previous layers.\n\nSee `references\u002Fmulti-stage-builds.md` for language-specific patterns (Go, Node, Python, Java).\n\n### Layer caching\n\nOrder Dockerfile instructions from least-frequently-changed to most-frequently-changed.\n\n1. Place dependency manifests (`package.json`, `go.mod`, `requirements.txt`) and install steps before copying application source code. Bind-mount the manifest into the install step instead of `COPY`-ing it, so it never enters a layer: `RUN --mount=type=bind,source=package.json,target=package.json --mount=type=bind,source=package-lock.json,target=package-lock.json npm ci`. This is safe for install commands that only read the manifest (`npm ci`, `pip install -r`, `go mod download`); if a step also needs to write the manifest back into the image, `COPY` it instead.\n2. Use BuildKit cache mounts for package manager caches:\n   - Go: `RUN --mount=type=cache,target=\u002Fgo\u002Fpkg\u002Fmod go build ...`\n   - Node: `RUN --mount=type=cache,target=\u002Froot\u002F.npm npm ci`\n   - Python: `RUN --mount=type=cache,target=\u002Froot\u002F.cache\u002Fpip pip install ...`\n   - apt: `RUN --mount=type=cache,target=\u002Fvar\u002Fcache\u002Fapt,sharing=locked --mount=type=cache,target=\u002Fvar\u002Flib\u002Fapt,sharing=locked apt-get update && apt-get install -y ...` — no `rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*` needed, since the cache lives outside the image layer. `sharing=locked` is required because apt needs exclusive access to its cache directories.\n   - apk (Alpine — per the Alpine wiki, not a Docker-verified doc; `references\u002Flayer-caching.md` links the source): `RUN --mount=type=cache,target=\u002Fetc\u002Fapk\u002Fcache,sharing=locked apk add ...` — drop `--no-cache` so downloaded packages land in the mounted cache directory instead of being discarded.\n3. Pin base image tags to a specific version or digest — never use `latest` in production.\n4. Combine related `RUN` commands with `&&` to reduce layer count, but keep logically distinct steps separate for cache granularity.\n\nSee `references\u002Flayer-caching.md` for detailed cache invalidation rules and cache mount patterns.\n\n### Build secrets and SSH access\n\nNever bake credentials into the image. Use BuildKit secrets and SSH mounts so credentials are available only during the specific `RUN` step that needs them, and never persist in any layer or `docker history` output.\n\n1. **Do NOT** pass credentials through `ARG` or `ENV`. Both end up in the image layers and are inspectable via `docker history`.\n2. **Do NOT** `COPY` credential files into the build context: `.npmrc`, `.pypirc`, `.netrc`, `pip.conf`, Maven `settings.xml`, `.env`, cloud credentials (`~\u002F.aws\u002Fcredentials`, `~\u002F.config\u002Fgcloud\u002F`, service-account JSON files, `~\u002F.azure\u002F`), secret-manager tokens (`~\u002F.vault-token`), package-registry tokens (`~\u002F.cargo\u002Fcredentials.toml`), TLS keys (`*.pem`, `*.p12`), `kubeconfig`, SSH keys (`id_rsa`, `id_dsa`, `id_ed25519`, `id_ecdsa`). Even when the final stage does not copy them forward, they live in intermediate layers and the build cache.\n3. **Do NOT** echo, write, or expand the secret value inside a `RUN` command in a way that persists it to a layer or emits it to build logs. Access the secret file (e.g., `\u002Frun\u002Fsecrets\u002F\u003Cid>`, or directly via the mount `target=`) — never `echo \"$(cat \u002Frun\u002Fsecrets\u002FX)\"`, never substitute it into a shell argument that will be logged with `--progress=plain`.\n4. **Use `RUN --mount=type=secret`** for package manager registry credentials:\n   ```dockerfile\n   RUN --mount=type=secret,id=npmrc,target=\u002Froot\u002F.npmrc,required=false \\\n       --mount=type=cache,target=\u002Froot\u002F.npm \\\n       npm ci --omit=dev\n   ```\n   The secret is available only inside that `RUN`, never written to a layer. Use `required=true` when the build will always need the credential (e.g., all packages come from a private registry, so missing the secret should fail the build immediately); use `required=false` only when the secret is optional (the build can succeed with public packages alone).\n5. **Use `RUN --mount=type=ssh`** for fetching private Git repositories or modules. The build container has no `known_hosts` by default — populate it inside the same `RUN`:\n   ```dockerfile\n   RUN --mount=type=ssh \\\n       mkdir -p -m 0700 \u002Froot\u002F.ssh && \\\n       ssh-keyscan github.com >> \u002Froot\u002F.ssh\u002Fknown_hosts && \\\n       git clone git@github.com:org\u002Fprivate-repo.git\n   ```\n   Do NOT use `StrictHostKeyChecking=no` as a shortcut — it disables host-key verification entirely. `ssh-keyscan` accepts whatever host key the server presents each time the step runs; nothing is pinned between builds. For stronger assurance, compare it against the provider's published host key fingerprints, or write the published key into `known_hosts` instead of scanning.\n6. **Invoke buildx with the secret and SSH sources:**\n   ```bash\n   # --ssh default forwards this shell's SSH agent (SSH_AUTH_SOCK); list every key the build can use:\n   ssh-add -l\n\n   docker buildx build \\\n       --secret id=npmrc,src=$HOME\u002F.npmrc \\\n       --ssh default \\\n       .\n   ```\n   The `RUN --mount=type=ssh` step can use every key that `ssh-add -l` lists, so expose only the key this build needs. In an interactive terminal, run `ssh-agent bash` to start a shell with a dedicated agent, then run `ssh-add \u003Ckey-file>`, confirm that `ssh-add -l` lists only that key, and run the build in that shell. A tool that starts a new shell for each command loses that agent between commands, so ask the user to run these steps. Alternatively, pass an unencrypted key file, such as a dedicated deploy key, directly with `--ssh default=\u003Ckey-file>`; BuildKit rejects passphrase-protected keys in this form, so load those into an agent instead.\n7. `.dockerignore` exclusions of `.env` and credential files are **defense in depth**, not the primary mechanism — keep them, but do not rely on them as your only protection.\n\nSee `references\u002Fmulti-stage-builds.md` for per-language patterns (npm, pip, Maven, Go `GOPRIVATE`).\n\n### .dockerignore\n\nAlways generate a `.dockerignore` alongside the Dockerfile. Exclude:\n\n- `.git\u002F`, `.github\u002F`, `.vscode\u002F`, `.idea\u002F`\n- `node_modules\u002F`, `__pycache__\u002F`, `.venv\u002F`, `vendor\u002F` (when rebuilt in the build stage)\n- `*.md`, `LICENSE`, `docs\u002F`\n- Build outputs, test artifacts, and IDE configs\n- `.env` files and any secrets\n\nSee `assets\u002Fdockerignore-example` for a comprehensive template.\n\n### Non-root user\n\nAlways configure the final image to run as a non-root user.\n\n1. Create a dedicated user and group in the runtime stage:\n   ```dockerfile\n   RUN addgroup --system --gid 1001 appgroup && \\\n       adduser --system --uid 1001 --ingroup appgroup appuser\n   ```\n2. Set ownership on application files: `COPY --from=build --chown=appuser:appgroup \u002Fapp \u002Fapp`\n3. When combining `--chown` with `COPY --link`, always use the numeric UID:GID you assigned (e.g., `--chown=1001:1001` if you used `--uid 1001 --gid 1001` above), not named users. `--link` creates an independent layer where named users from prior `RUN` instructions are not available.\n4. Place the `USER appuser` instruction after all file operations and before `ENTRYPOINT`\u002F`CMD`.\n5. On distroless images, use the built-in nonroot user: `USER nonroot:nonroot`.\n\n### Image size optimization\n\n1. Prefer `FROM scratch` (Go static binaries), distroless, or Alpine-based images for the runtime stage.\n2. Install OS packages with a BuildKit cache mount rather than `rm -rf`-ing the cache in the same layer — see \"Layer caching\" above. The cache mount keeps the package cache out of the image layer entirely, so no cleanup step is needed.\n3. Do not install documentation, man pages, or debug tools in the runtime image.\n4. Use `.dockerignore` aggressively to minimize the build context.\n\n### General rules\n\n- Always include a `# syntax=docker\u002Fdockerfile:1` directive as the first line to enable BuildKit features.\n- Set `WORKDIR` before any `COPY` or `RUN` instructions — never rely on the default `\u002F`.\n- Prefer `ENTRYPOINT` with exec form (`[\"binary\"]`) over shell form.\n- Add `EXPOSE` to document the listening port.\n- Add metadata labels: `LABEL org.opencontainers.image.source=...`\n\n## Related skills\n\n- For first-time Docker project scaffolding and deciding which files to create, use `docker-project-foundations`.\n- For service dependencies, health checks, overrides, networks, and volume patterns, use `docker-compose-patterns`.\n- For destructive Docker CLI commands (`docker system prune`, `docker rm -f`, image\u002Fnetwork\u002Fbuilder pruning) and a cross-product index of destructive-command guardrails, use `docker-destructive-guardrails`.\n\n## References\n\n- `references\u002Fmulti-stage-builds.md` — Language-specific multi-stage patterns for Go, Node.js, Python, and Java\n- `references\u002Flayer-caching.md` — Deep dive on layer ordering, cache invalidation, and BuildKit cache mounts\n\n## Assets\n\n- `assets\u002FDockerfile.go` — Multi-stage Go build with distroless runtime and non-root user\n- `assets\u002FDockerfile.nodejs` — Multi-stage Node.js build with proper layer caching and non-root user\n- `assets\u002FDockerfile.python` — Python build with virtual env, layer ordering, and non-root user\n- `assets\u002Fdockerignore-example` — Comprehensive `.dockerignore` template\n\n## Scripts\n\n- **`scripts\u002Fverify-build.sh`** — Builds the Dockerfile in the current directory, then reports image size and configured user. Run it from the project root (the directory that contains the `Dockerfile`), with the script path resolved under this skill's directory:\n  ```bash\n  bash \"\u003Cskill-dir>\u002Fscripts\u002Fverify-build.sh\" [--help] [IMAGE_NAME]\n  ```\n  Replace `\u003Cskill-dir>` with the absolute path of the folder that contains this `SKILL.md`; the `scripts\u002F` path is relative to that folder, not to the project. Do not change into the skill directory first: the script builds whatever is in the current directory. If the skill directory cannot be resolved, run `docker build -t verify-build-test .`, then `docker images verify-build-test` and `docker inspect verify-build-test --format '{{.Config.User}}'`. Exit status is `0` when all Docker commands succeed or help is requested, the failing Docker command's non-zero status when verification fails, and `2` for invalid arguments.\n\n## Checks\n\n- `checks\u002Fverification.md` — Detailed verification runbook for manual review.\n","# Docker Build Strategies\n\n## Overview\n\nThis skill provides rules and patterns for writing and reviewing production-quality Dockerfiles. Apply it when the main task is image-build quality: multi-stage builds, cache behavior, non-root execution, build context hygiene, and runtime image size.\n\n## When to use this skill\n\nActivate this skill when:\n\n- Creating a new Dockerfile for any language or framework\n- Optimizing an existing Dockerfile for size, speed, or security\n- Reviewing a Dockerfile for best-practice compliance\n- Adding a `.dockerignore` file to a project\n\n## Do not use this skill when\n\nDo not use this skill when:\n\n- The project has no Docker setup yet and the main need is a first-pass scaffold\n- The main task is wiring services together in `compose.yaml`\n- The main task is debugging Compose startup ordering, networking, or development overrides\n\n## Core guidance\n\n### Multi-stage builds\n\nUse multi-stage builds when the project has a build step or when build-time dependencies differ from runtime. Separate build-time dependencies from the runtime image.\n\n1. Name every stage explicitly (`FROM ... AS build`, `FROM ... AS runtime`).\n2. Use the smallest appropriate base for the runtime stage: `distroless`, `alpine`, or `slim` variants.\n3. Copy only the final artifact into the runtime stage with `COPY --from=build`.\n4. Use `COPY --link` when copying from a prior stage or adding static files — it improves cache reuse by making the COPY independent of previous layers.\n\nSee `references\u002Fmulti-stage-builds.md` for language-specific patterns (Go, Node, Python, Java).\n\n### Layer caching\n\nOrder Dockerfile instructions from least-frequently-changed to most-frequently-changed.\n\n1. Place dependency manifests (`package.json`, `go.mod`, `requirements.txt`) and install steps before copying application source code. Bind-mount the manifest into the install step instead of `COPY`-ing it, so it never enters a layer: `RUN --mount=type=bind,source=package.json,target=package.json --mount=type=bind,source=package-lock.json,target=package-lock.json npm ci`. This is safe for install commands that only read the manifest (`npm ci`, `pip install -r`, `go mod download`); if a step also needs to write the manifest back into the image, `COPY` it instead.\n2. Use BuildKit cache mounts for package manager caches:\n   - Go: `RUN --mount=type=cache,target=\u002Fgo\u002Fpkg\u002Fmod go build ...`\n   - Node: `RUN --mount=type=cache,target=\u002Froot\u002F.npm npm ci`\n   - Python: `RUN --mount=type=cache,target=\u002Froot\u002F.cache\u002Fpip pip install ...`\n   - apt: `RUN --mount=type=cache,target=\u002Fvar\u002Fcache\u002Fapt,sharing=locked --mount=type=cache,target=\u002Fvar\u002Flib\u002Fapt,sharing=locked apt-get update && apt-get install -y ...` — no `rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*` needed, since the cache lives outside the image layer. `sharing=locked` is required because apt needs exclusive access to its cache directories.\n   - apk (Alpine — per the Alpine wiki, not a Docker-verified doc; `references\u002Flayer-caching.md` links the source): `RUN --mount=type=cache,target=\u002Fetc\u002Fapk\u002Fcache,sharing=locked apk add ...` — drop `--no-cache` so downloaded packages land in the mounted cache directory instead of being discarded.\n3. Pin base image tags to a specific version or digest — never use `latest` in production.\n4. Combine related `RUN` commands with `&&` to reduce layer count, but keep logically distinct steps separate for cache granularity.\n\nSee `references\u002Flayer-caching.md` for detailed cache invalidation rules and cache mount patterns.\n\n### Build secrets and SSH access\n\nNever bake credentials into the image. Use BuildKit secrets and SSH mounts so credentials are available only during the specific `RUN` step that needs them, and never persist in any layer or `docker history` output.\n\n1. **Do NOT** pass credentials through `ARG` or `ENV`. Both end up in the image layers and are inspectable via `docker history`.\n2. **Do NOT** `COPY` credential files into the build context: `.npmrc`, `.pypirc`, `.netrc`, `pip.conf`, Maven `settings.xml`, `.env`, cloud credentials (`~\u002F.aws\u002Fcredentials`, `~\u002F.config\u002Fgcloud\u002F`, service-account JSON files, `~\u002F.azure\u002F`), secret-manager tokens (`~\u002F.vault-token`), package-registry tokens (`~\u002F.cargo\u002Fcredentials.toml`), TLS keys (`*.pem`, `*.p12`), `kubeconfig`, SSH keys (`id_rsa`, `id_dsa`, `id_ed25519`, `id_ecdsa`). Even when the final stage does not copy them forward, they live in intermediate layers and the build cache.\n3. **Do NOT** echo, write, or expand the secret value inside a `RUN` command in a way that persists it to a layer or emits it to build logs. Access the secret file (e.g., `\u002Frun\u002Fsecrets\u002F\u003Cid>`, or directly via the mount `target=`) — never `echo \"$(cat \u002Frun\u002Fsecrets\u002FX)\"`, never substitute it into a shell argument that will be logged with `--progress=plain`.\n4. **Use `RUN --mount=type=secret`** for package manager registry credentials:\n   ```dockerfile\n   RUN --mount=type=secret,id=npmrc,target=\u002Froot\u002F.npmrc,required=false \\\n       --mount=type=cache,target=\u002Froot\u002F.npm \\\n       npm ci --omit=dev\n   ```\n   The secret is available only inside that `RUN`, never written to a layer. Use `required=true` when the build will always need the credential (e.g., all packages come from a private registry, so missing the secret should fail the build immediately); use `required=false` only when the secret is optional (the build can succeed with public packages alone).\n5. **Use `RUN --mount=type=ssh`** for fetching private Git repositories or modules. The build container has no `known_hosts` by default — populate it inside the same `RUN`:\n   ```dockerfile\n   RUN --mount=type=ssh \\\n       mkdir -p -m 0700 \u002Froot\u002F.ssh && \\\n       ssh-keyscan github.com >> \u002Froot\u002F.ssh\u002Fknown_hosts && \\\n       git clone git@github.com:org\u002Fprivate-repo.git\n   ```\n   Do NOT use `StrictHostKeyChecking=no` as a shortcut — it disables host-key verification entirely. `ssh-keyscan` accepts whatever host key the server presents each time the step runs; nothing is pinned between builds. For stronger assurance, compare it against the provider's published host key fingerprints, or write the published key into `known_hosts` instead of scanning.\n6. **Invoke buildx with the secret and SSH sources:**\n   ```bash\n   # --ssh default forwards this shell's SSH agent (SSH_AUTH_SOCK); list every key the build can use:\n   ssh-add -l\n\n   docker buildx build \\\n       --secret id=npmrc,src=$HOME\u002F.npmrc \\\n       --ssh default \\\n       .\n   ```\n   The `RUN --mount=type=ssh` step can use every key that `ssh-add -l` lists, so expose only the key this build needs. In an interactive terminal, run `ssh-agent bash` to start a shell with a dedicated agent, then run `ssh-add \u003Ckey-file>`, confirm that `ssh-add -l` lists only that key, and run the build in that shell. A tool that starts a new shell for each command loses that agent between commands, so ask the user to run these steps. Alternatively, pass an unencrypted key file, such as a dedicated deploy key, directly with `--ssh default=\u003Ckey-file>`; BuildKit rejects passphrase-protected keys in this form, so load those into an agent instead.\n7. `.dockerignore` exclusions of `.env` and credential files are **defense in depth**, not the primary mechanism — keep them, but do not rely on them as your only protection.\n\nSee `references\u002Fmulti-stage-builds.md` for per-language patterns (npm, pip, Maven, Go `GOPRIVATE`).\n\n### .dockerignore\n\nAlways generate a `.dockerignore` alongside the Dockerfile. Exclude:\n\n- `.git\u002F`, `.github\u002F`, `.vscode\u002F`, `.idea\u002F`\n- `node_modules\u002F`, `__pycache__\u002F`, `.venv\u002F`, `vendor\u002F` (when rebuilt in the build stage)\n- `*.md`, `LICENSE`, `docs\u002F`\n- Build outputs, test artifacts, and IDE configs\n- `.env` files and any secrets\n\nSee `assets\u002Fdockerignore-example` for a comprehensive template.\n\n### Non-root user\n\nAlways configure the final image to run as a non-root user.\n\n1. Create a dedicated user and group in the runtime stage:\n   ```dockerfile\n   RUN addgroup --system --gid 1001 appgroup && \\\n       adduser --system --uid 1001 --ingroup appgroup appuser\n   ```\n2. Set ownership on application files: `COPY --from=build --chown=appuser:appgroup \u002Fapp \u002Fapp`\n3. When combining `--chown` with `COPY --link`, always use the numeric UID:GID you assigned (e.g., `--chown=1001:1001` if you used `--uid 1001 --gid 1001` above), not named users. `--link` creates an independent layer where named users from prior `RUN` instructions are not available.\n4. Place the `USER appuser` instruction after all file operations and before `ENTRYPOINT`\u002F`CMD`.\n5. On distroless images, use the built-in nonroot user: `USER nonroot:nonroot`.\n\n### Image size optimization\n\n1. Prefer `FROM scratch` (Go static binaries), distroless, or Alpine-based images for the runtime stage.\n2. Install OS packages with a BuildKit cache mount rather than `rm -rf`-ing the cache in the same layer — see \"Layer caching\" above. The cache mount keeps the package cache out of the image layer entirely, so no cleanup step is needed.\n3. Do not install documentation, man pages, or debug tools in the runtime image.\n4. Use `.dockerignore` aggressively to minimize the build context.\n\n### General rules\n\n- Always include a `# syntax=docker\u002Fdockerfile:1` directive as the first line to enable BuildKit features.\n- Set `WORKDIR` before any `COPY` or `RUN` instructions — never rely on the default `\u002F`.\n- Prefer `ENTRYPOINT` with exec form (`[\"binary\"]`) over shell form.\n- Add `EXPOSE` to document the listening port.\n- Add metadata labels: `LABEL org.opencontainers.image.source=...`\n\n## Related skills\n\n- For first-time Docker project scaffolding and deciding which files to create, use `docker-project-foundations`.\n- For service dependencies, health checks, overrides, networks, and volume patterns, use `docker-compose-patterns`.\n- For destructive Docker CLI commands (`docker system prune`, `docker rm -f`, image\u002Fnetwork\u002Fbuilder pruning) and a cross-product index of destructive-command guardrails, use `docker-destructive-guardrails`.\n\n## References\n\n- `references\u002Fmulti-stage-builds.md` — Language-specific multi-stage patterns for Go, Node.js, Python, and Java\n- `references\u002Flayer-caching.md` — Deep dive on layer ordering, cache invalidation, and BuildKit cache mounts\n\n## Assets\n\n- `assets\u002FDockerfile.go` — Multi-stage Go build with distroless runtime and non-root user\n- `assets\u002FDockerfile.nodejs` — Multi-stage Node.js build with proper layer caching and non-root user\n- `assets\u002FDockerfile.python` — Python build with virtual env, layer ordering, and non-root user\n- `assets\u002Fdockerignore-example` — Comprehensive `.dockerignore` template\n\n## Scripts\n\n- **`scripts\u002Fverify-build.sh`** — Builds the Dockerfile in the current directory, then reports image size and configured user. Run it from the project root (the directory that contains the `Dockerfile`), with the script path resolved under this skill's directory:\n  ```bash\n  bash \"\u003Cskill-dir>\u002Fscripts\u002Fverify-build.sh\" [--help] [IMAGE_NAME]\n  ```\n  Replace `\u003Cskill-dir>` with the absolute path of the folder that contains this `SKILL.md`; the `scripts\u002F` path is relative to that folder, not to the project. Do not change into the skill directory first: the script builds whatever is in the current directory. If the skill directory cannot be resolved, run `docker build -t verify-build-test .`, then `docker images verify-build-test` and `docker inspect verify-build-test --format '{{.Config.User}}'`. Exit status is `0` when all Docker commands succeed or help is requested, the failing Docker command's non-zero status when verification fails, and `2` for invalid arguments.\n\n## Checks\n\n- `checks\u002Fverification.md` — Detailed verification runbook for manual review.\n",{"name":5,"license":14,"description":7,"compatibility":23},"Requires Docker 23.0+ (BuildKit default). On Docker 20.10–22.x, set DOCKER_BUILDKIT=1 before building.","main","18e26686a1432c54293deba762caad02ba886925","upstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002FRainbow609","2026-11-15 11:39:03",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add Rainbow609\u002Fagent-skills --skill docker-build-strategies",{"tool":36,"command":37},"bunx","bunx skills add Rainbow609\u002Fagent-skills --skill docker-build-strategies",{"tool":39,"command":40},"pnpm","pnpm dlx skills add Rainbow609\u002Fagent-skills --skill docker-build-strategies","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002FSKILL.md",true,[44,50,56,62,66,70,74,78,82,86],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"agents\u002Fopenai.yaml","REFERENCE","参考文档",256,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fagents\u002Fopenai.yaml",{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"assets\u002FDockerfile.go","SCRIPT","脚本",821,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fassets\u002FDockerfile.go",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"assets\u002FDockerfile.nodejs","ASSET","资产文件",1661,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fassets\u002FDockerfile.nodejs",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"assets\u002FDockerfile.python",1065,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fassets\u002FDockerfile.python",{"path":67,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":68,"sourceHtmlUrl":69},"assets\u002Fdockerignore-example",644,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fassets\u002Fdockerignore-example",{"path":71,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":72,"sourceHtmlUrl":73},"checks\u002Fverification.md",6307,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fchecks\u002Fverification.md",{"path":75,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Flayer-caching.md",6123,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Freferences\u002Flayer-caching.md",{"path":79,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fmulti-stage-builds.md",8767,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Freferences\u002Fmulti-stage-builds.md",{"path":83,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":84,"sourceHtmlUrl":85},"scripts\u002Fverify-build.sh",903,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fscripts\u002Fverify-build.sh",{"path":87,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":88,"sourceHtmlUrl":89},"skill.yaml",773,"https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-build-strategies\u002Fskill.yaml",[91,100,108,115,122,129],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":95,"licenseFileUrl":96,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":18},"01M7EN4N53ENQWQE5NDRT64NDC","archify","Create validated architecture, workflow, sequence, data-flow, lifecycle\u002Fstate, entity-relationship, class\u002Finterface, tree, timeline, and execution waterfall diagrams as explorable standalone HTML with inline SVG, dark\u002Flight themes, optional motion, and image\u002FSVG\u002FWebM export. Accept plain-language requirements or Mermaid; inspect repository evidence for code-backed diagrams. Use when visualizing infrastructure, cloud\u002Fsecurity networks, API calls, data pipelines, ETL\u002FELT, state machines, database schemas, class contracts, module hierarchies, incident\u002Frelease histories, or request and agent-run timings. Also use for everyday subjects with steps, parts, relationships, or states: leave and travel plans, applications and approvals, renting conversations, money or document flows, and order progress. Not for numeric charts or dashboards.","MIT","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Ftt-a1i\u002Farchify\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Ftt-a1i\u002Farchify\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":95,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":18},"01M7EN4GGKJXFVK85685S30141","distilly","Set up the owner profile so a personal agent knows who it works for (first-run setup, \"get to know me\"), or distill colleague, relationship, or celebrity source material into reusable Person Profiles for agents.","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Ftitanwings\u002Fdistilly\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Ftitanwings\u002Fdistilly\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":18},"01M7EMZQREVCNAJA9DY7NQ7M7Q","docker-sandboxes-network-credentials","Use this skill when configuring what a Docker Sandboxes (`sbx`) sandbox can reach on the network or which credentials it authenticates with, even if the user just says they want to \"let the agent call an internal API\", \"block all network access\", \"give the agent a GitHub token\", or \"use a private registry image for a sandbox\". Covers `sbx policy init\u002Fallow\u002Fdeny\u002Fls\u002Finspect\u002Flog\u002Fcheck\u002Frm network` (global and per-sandbox egress rules, deny-over-allow precedence) and `sbx secret set\u002Fset-custom\u002Fls\u002Frm\u002Fimport` (service secrets, dynamic secrets via --ref\u002F--command, and registry pull credentials with their host-pulls-only-by-default injection scope).","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-sandboxes-network-credentials\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":18},"01M7EMZE6V7A70RR2AMMDAGP3S","docker-sandboxes-lifecycle","Use this skill when creating, running, reattaching to, listing, stopping, or removing Docker Sandboxes (the standalone `sbx` CLI that runs AI coding agents in isolated microVMs), even if the user just says they want to \"run claude in a sandbox\", \"isolate an agent from my repo\", \"give an agent its own git clone\", or \"clean up old sandboxes\". Covers `sbx run`\u002F`sbx create` (including the built-in agents claude, codex, cursor, devin, docker-agent, gemini, opencode, shell), workspace bind-mount vs `--clone` isolation, additional read-only workspaces, reattaching by `--name`, `sbx ls`\u002F`stop`\u002F`rm`\u002F`prune`, `sbx exec`, `sbx cp`, and `sbx ports`.","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-sandboxes-lifecycle\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":18},"01M7EMZ2BN8Z7P5H557RS8WYP2","docker-sandboxes-kits","Use this skill when authoring, validating, packaging, signing, or composing a Docker Sandboxes kit `spec.yaml` (`sbx kit add\u002Finspect\u002Fpack\u002Fpull\u002Fpush\u002Fsign\u002Fvalidate\u002Fverify`), even if the user just says they want to \"add a tool to a sandbox agent\", \"build a reusable sandbox extension\", \"publish a kit to a registry\", or \"give a mixin its own credentials and network access\". Covers the kit-spec v2 grammar (`kind: sandbox` vs `kind: mixin`, the `sandbox:` block, `permissions.network`, `ports`, `credentials` apiKey\u002Foauth, `environment`, `setup` install\u002Fstartup\u002Ffiles, `volumes`, `args`, `extends`, `mixins`, `requires.agent`), composition via `--kit`\u002F`sbx kit add`, and distribution (pack\u002Fpush\u002Fpull\u002Fsign\u002Fverify\u002Fprovenance).","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-sandboxes-kits\u002FSKILL.md",[],[],{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":18},"01M7EMYQZXA60B14ZQEXMSWNVG","docker-sandboxes-env","Use this skill when authoring, planning, or running a declarative `sbxenv.yaml` file for Docker Sandboxes (`sbx env create\u002Frun\u002Fplan\u002Fexec\u002Frm`), even if the user just says they want to \"check in a sandbox config\", \"make onboarding reproducible for a sandbox\", \"run a setup script before the agent starts\", or \"define arguments for a shared sandbox environment\". Covers the sbxenv.yaml schema (schemaVersion, agent, kits, workspace\u002FadditionalWorkspaces, args, env, secrets, registries, bindings, mcp, ports, sandboxOptions), host `lifecycle:` commands (initialize\u002FpostCreate\u002FpreRemove) and their approval-plan model, multi-file merge (`-f`-style deep merge and the user-level `.sbxenv.yaml` base layer), and file-write-protection (`sandboxOptions.writableEnvFiles`).","https:\u002F\u002Fgithub.com\u002FRainbow609\u002Fagent-skills\u002Fblob\u002Fmain\u002Fupstream\u002Fdocker\u002Fskills\u002Fdocker-sandboxes-env\u002FSKILL.md",[],[]]