docker-development
它能做什么
这项技能引导智能体编写、优化和审查 Docker 容器配置。适合希望容器构建快、体积小、运行安全的开发者。
适用场景
- ✓当你的 Docker 构建很慢,或镜像过大的时候。
- ✓当你想为项目设置 docker-compose 文件时。
- ✓当你想在发布前检查 Dockerfile 的安全问题的时候。
技能链接
https://github.com/alirezarezvani/claude-skills/blob/main/engineering/docker-development/skills/docker-development/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 Docker 镜像太大,构建也很慢。请针对体积和缓存优化 Dockerfile。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会分析 Dockerfile 的镜像层、缓存和体积,然后建议修改,例如多阶段构建。它还会验证 compose 文件,并审计 Dockerfile 或正在运行的容器中的安全问题。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Docker Development
Smaller images. Faster builds. Secure containers. No guesswork.
Opinionated Docker workflow that turns bloated Dockerfiles into production-grade containers. Covers optimization, multi-stage builds, compose orchestration, and security hardening.
Not a Docker tutorial — a set of concrete decisions about how to build containers that don't waste time, space, or attack surface.
Slash Commands
| Command | What it does |
|---|---|
/docker-development optimize |
Analyze and optimize a Dockerfile for size, speed, and layer caching |
/docker-development compose |
Generate or improve docker-compose.yml with best practices |
/docker-development security |
Audit a Dockerfile or running container for security issues |
When This Skill Activates
Recognize these patterns from the user:
- "Optimize this Dockerfile"
- "My Docker build is slow"
- "Create a docker-compose for this project"
- "Is this Dockerfile secure?"
- "Reduce my Docker image size"
- "Set up multi-stage builds"
- "Docker best practices for [language/framework]"
- Any request involving: Dockerfile, docker-compose, container, image size, build cache, Docker security
If the user has a Dockerfile or wants to containerize something → this skill applies.
Workflow
/docker-development optimize — Dockerfile Optimization
Analyze current state
- Read the Dockerfile
- Identify base image and its size
- Count layers (each RUN/COPY/ADD = 1 layer)
- Check for common anti-patterns
Apply optimization checklist
BASE IMAGE ├── Use specific tags, never :latest in production ├── Prefer slim/alpine variants (debian-slim > ubuntu > debian) ├── Pin digest for reproducibility in CI: image@sha256:... └── Match base to runtime needs (don't use python:3.12 for a compiled binary) LAYER OPTIMIZATION ├── Combine related RUN commands with && \ ├── Order layers: least-changing first (deps before source code) ├── Clean package manager cache in the same RUN layer ├── Use .dockerignore to exclude unnecessary files └── Separate build deps from runtime deps BUILD CACHE ├── COPY dependency files before source code (package.json, requirements.txt, go.mod) ├── Install deps in a separate layer from code copy ├── Use BuildKit cache mounts: --mount=type=cache,target=/root/.cache └── Avoid COPY . . before dependency installation MULTI-STAGE BUILDS ├── Stage 1: build (full SDK, build tools, dev deps) ├── Stage 2: runtime (minimal base, only production artifacts) ├── COPY --from=builder only what's needed └── Final image should have NO build tools, NO source code, NO dev depsGenerate optimized Dockerfile
- Apply all relevant optimizations
- Add inline comments explaining each decision
- Report estimated size reduction
Validate
python3 scripts/dockerfile_analyzer.py Dockerfile
/docker-development compose — Docker Compose Configuration
Identify services
- Application (web, API, worker)
- Database (postgres, mysql, redis, mongo)
- Cache (redis, memcached)
- Queue (rabbitmq, kafka)
- Reverse proxy (nginx, traefik, caddy)
Apply compose best practices
SERVICES ├── Use depends_on with condition: service_healthy ├── Add healthchecks for every service ├── Set resource limits (mem_limit, cpus) ├── Use named volumes for persistent data └── Pin image versions NETWORKING ├── Create explicit networks (don't rely on default) ├── Separate frontend and backend networks ├── Only expose ports that need external access └── Use internal: true for backend-only networks ENVIRONMENT ├── Use env_file for secrets, not inline environment ├── Never commit .env files (add to .gitignore) ├── Use variable substitution: ${VAR:-default} └── Document all required env vars DEVELOPMENT vs PRODUCTION ├── Use compose profiles or override files ├── Dev: bind mounts for hot reload, debug ports exposed ├── Prod: named volumes, no debug ports, restart: unless-stopped └── docker-compose.override.yml for dev-only configGenerate compose file
- Output docker-compose.yml with healthchecks, networks, volumes
- Generate .env.example with all required variables documented
- Add dev/prod profile annotations
/docker-development security — Container Security Audit
- **Dockerfile
常见问题
什么是多阶段构建?
一种 Dockerfile,先用一个阶段构建应用,再用更小的阶段运行,从而使最终镜像更精简。
它能检查正在运行的容器吗?
能。安全命令可以审计 Dockerfile 或正在运行的容器。
它对 docker-compose 有帮助吗?
有。它可以按照最佳实践生成或改进 docker-compose 文件。
详情
作者的原始描述
Use for any Dockerfile or docker-compose file to write, optimize or review, before editing it. Checks layers, caching, size and security with dockerfile_analyzer.py and validates compose files with compose_validator.py.
热度
- GitHub 星标
- 29k
- 排名
- #9555
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-launcher-orchestrator
29k帮你的智能体从一个清晰的目标出发,逐步规划、构建、测试并定时运行你自己账户中的 Claude 托管智能体。
grade-iterate
29k让你的智能体按评分标准为托管 AI 智能体的工作打分,并在固定的轮次内改进,因此它永远不会无限循环。
interview
29k让你的智能体就一个 AI 智能体的想法对你进行访谈,并在任何上线之前,把你的回答整理成一份简单的构建计划。
run-without-you
29k帮你的智能体设置托管 AI 智能体,使其按计划或在某个事件发生时运行,并在启动前检查定时设置。