dockerfile-optimise
БесплатноБез исполняемых скриптовНе проверенDockerfile optimization guidelines from official Docker documentation. This skill should be used when writing, reviewing, or refactoring Dockerfiles to ensure…
от pproenca★ 231 звезда на GitHubОб этом скилле
Dockerfile Optimization Best Practices
Comprehensive Dockerfile optimization guide sourced exclusively from official Docker documentation. Contains 48 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Writing new Dockerfiles or modifying existing ones
- Optimizing Docker build times (layer caching, cache mounts, context management)
- Reducing Docker image size (multi-stage builds, minimal base images)
- Hardening container security (secret mounts, non-root users, attestations)
- Setting up CI/CD pipelines with Docker builds
- Reviewing Dockerfiles for anti-patterns
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Layer Caching & Ordering | CRITICAL | cache- |
| 2 | Multi-Stage Builds | CRITICAL | stage- |
| 3 | Base Image Selection | HIGH | base- |
| 4 | Build Context Management | HIGH | ctx- |
| 5 | Security & Secrets | HIGH | sec- |
| 6 | Dependency Management | MEDIUM-HIGH | dep- |
| 7 | Instruction Patterns | MEDIUM | inst- |
| 8 | Quality & Validation | MEDIUM | lint- |
Quick Reference
1. Layer Caching & Ordering (CRITICAL)
cache-layer-order- Order layers by change frequencycache-copy-deps-first- Copy dependency files before source codecache-copy-link- Use COPY --link for cache-efficient layer copyingcache-mount-package- Use cache mounts for package managerscache-apt-combine- Combine apt-get update with installcache-external- Use external cache for CI/CD buildscache-invalidation- Avoid unnecessary cache invalidationcache-minimize-layers- Consolidate related RUN instructions
2. Multi-Stage Builds (CRITICAL)
stage-separate-build-runtime- Separate build and runtime stagesstage-named-stages- Use named build stagesstage-parallel-branches- Exploit parallel stage executionstage-target-builds- Use target builds for dev/prodstage-copy-artifacts-only- Copy only final artifacts between stagesstage-reusable-base- Create reusable base stages
3. Base Image Selection (HIGH)
base-minimal-image- Use minimal base imagesbase-official-images- Use Docker Official Imagesbase-pin-versions- Pin base image versions with digestsbase-arg-version- Use ARG before FROM to parameterize base imagesbase-rebuild-regularly- Rebuild images regularly with --pullbase-distroless- Use distroless or scratch images for production
4. Build Context Management (HIGH)
ctx-dockerignore- Use .dockerignore to exclude unnecessary filesctx-bind-mounts- Use bind mounts instead of COPY for build-only filesctx-minimize-context- Keep build context smallctx-syntax-directive- Use syntax directive for latest BuildKit features (prerequisite for cache mounts, secret mounts, heredocs, COPY --link)
5. Security & Secrets (HIGH)
sec-secret-mounts- Use secret mounts for sensitive datasec-non-root-user- Run as non-root usersec-no-secrets-in-args- Never pass secrets via ARG or ENVsec-ssh-mounts- Use SSH mounts for private repository accesssec-attestations- Enable SBOM and provenance attestationssec-no-unnecessary-packages- Avoid installing unnecessary packagessec-ephemeral-containers- Design ephemeral, stateless containers
6. Dependency Management (MEDIUM-HIGH)
dep-cache-mount-apt- Use cache mount for apt package managerdep-cache-mount-npm- Use cache mount for npm, yarn, and pnpmdep-cache-mount-pip- Use cache mount for pipdep-version-pin- Pin package versions for repr
Установить dockerfile-optimise в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл dockerfile-optimise?
Dockerfile optimization guidelines from official Docker documentation. This skill should be used when writing, reviewing, or refactoring Dockerfiles to ensure optimal build time, image size, security, and robustness. Triggers on tasks involving Dockerfile creation, Docker image builds, container optimization, multi-stage builds, build cache, or Docker security hardening.
Как установить скилл dockerfile-optimise?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dockerfile-optimise запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic