‹ 首页

docker

@avibebuilder · 收录于 1 周前

ALWAYS activate when the user's query involves Docker in any way — even if it also matches other skills. If the words docker, Dockerfile, docker-compose, compose.yml, container, or image appear in the query, this skill MUST be used. Covers: writing or editing Dockerfiles and compose files, adding services (postgres, redis, etc.) to compose, volume mounts and data persistence, docker build failures (layer caching, npm install issues), healthchecks and service startup ordering (depends_on), environment variables in containers, port mapping, container crashes and exit codes (OOM/137), non-root users, multi-stage builds, image optimization, .dockerignore, and deploying to container runtimes. Takes priority over general implementation or debugging skills when Docker infrastructure is the subject.

适合你,如果经常用 Docker 管理应用容器和部署环境

/ 下载安装
docker.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add avibebuilder/claude-prime/docker
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- avibebuilder/claude-prime/docker
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify avibebuilder/claude-prime/docker
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
106GitHub stars
~890最小装载
~2.5K含声明引用
~2.5K文本包总量
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · 80bcfa4

Docker

Project-specific containerization patterns for Dockerfile and Docker Compose.

Architecture Decisions
Image Building
  1. Minimal base images — Use slim/alpine variants; pin to digest for reproducibility.
  2. Multi-stage builds — Separate build dependencies from runtime.
  3. Layer optimization — Combine RUN commands; place frequently changed files last.
  4. COPY over ADD — ADD only for tar extraction or remote URLs.
Security
  1. Non-root users — Always use UID >10000; never run as root in production.
  2. No secrets in images — Use Docker secrets or runtime env injection.
  3. .dockerignore required — Exclude .git, .env, node_modules, build artifacts.
Runtime
  1. One process per container — Single responsibility principle.
  2. Healthchecks required — Define HEALTHCHECK in Dockerfile or Compose.
  3. Resource limits — Always set mem_limit and cpus in production.
Compose
  1. Network segmentation — Dedicated networks per service group.
  2. Named volumes — Never use anonymous volumes in production.
  3. depends_on with healthchecks — Use condition: service_healthy.
  4. Environment separation — Use override files for dev/staging/prod.
Gotchas
  • COPY . . before RUN npm install busts the cache on EVERY code change. Copy package*.json first, install, THEN copy source.
  • Alpine uses musl libc, not glibc. Python packages with C extensions (numpy, pandas, cryptography) may fail to install or need apk add build dependencies. Consider -slim variants if you hit this.
  • ENTRYPOINT ["python", "app.py"] (exec form) handles signals correctly. ENTRYPOINT python app.py (shell form) wraps in /bin/sh -c and PID 1 won't receive SIGTERM — containers take 10s to stop.
  • Docker layer cache is invalidated from the FIRST changed layer downward. A changed COPY near the top rebuilds everything below it.
  • depends_on without condition: service_healthy only waits for container START, not readiness. Your app will crash connecting to a database that's still initializing.
  • host.docker.internal works on Docker Desktop (Mac/Windows) but NOT on Linux. Use --network host or explicit container networking on Linux.
  • Build args (ARG) are NOT available after FROM in multi-stage builds unless re-declared. Each stage starts fresh.
  • docker compose up reuses existing containers. After changing Dockerfile, you need docker compose up --build or docker compose build first.
  • Volume mounts override the container's filesystem — if your node_modules are built inside the container but you mount .:/app, the host's (possibly empty) node_modules shadows them. Use a named volume for node_modules.
  • EXPOSE is documentation only — it does NOT publish the port. You still need -p 8080:8080 or ports: in compose.
  • Docker's default bridge network does NOT provide DNS resolution between containers. Use a custom network or compose's default network.
References

| When you need... | Read | |------------------|------| | Dockerfile patterns, CMD vs ENTRYPOINT | [dockerfile.md](./references/dockerfile.md) | | Compose services, networks, volumes | [compose.md](./references/compose.md) | | Security hardening | [security.md](./references/security.md) | | Production deployment | [production.md](./references/production.md) |

按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。