- name
SKILL.md
技能檔案保留在發布者的儲存庫中。
在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add docker/skills --skill docker-project-foundations -a cursor -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add docker/skills --skill docker-project-foundations -a claude-code -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add docker/skills --skill docker-project-foundations -a codex -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add docker/skills --skill docker-project-foundations -a grok -y在 Grok Bot 聊天中傳送複製的訊息。Bot 會從 GitHub 取得這個 SKILL.md,並加入你所有 Bot 共用的技能中。
Install this skill: https://github.com/docker/skills/tree/HEAD/skills/docker-project-foundations來自發布者
This skill guides you in Dockerizing a project from scratch. It focuses on creating the initial Docker file set, choosing a sane layout, and preferring containerized dependencies over host-level installs.
Activate this skill when:
Dockerfile, compose.yaml, or .dockerignore and does not have oneDo not use this skill when:
DockerfileWhen Dockerizing a project, always produce all three:
.dockerignore — Create this first so the initial build context is small and safe. See assets/dockerignore-example for a reference.Dockerfile — Create a working starter image definition that the project can build and run with. Start from assets/Dockerfile.simple and keep its baseline, even for a first scaffold:
node:22-slim), never latest;package.json + lockfile) copied before the source for layer caching;USER set in the final stage before CMD/ENTRYPOINT.compose.yaml — Create a local development stack that includes the application service and any required dependencies. See assets/compose-dev.yaml..npmrc at every depth with **/.npmrc in .dockerignore; otherwise a broad source copy can persist credentials in image layers.npmrc as a BuildKit secret for both npm ci steps. Public-package builds need no secret. For private registries, pass the config explicitly:
DOCKER_BUILDKIT=1 docker build --secret id=npmrc,src="$HOME/.npmrc" .
Use the actual config path if the project keeps it elsewhere. Never copy the credential file or pass its values through ARG or ENV. Dependency scripts run during installation can access the mounted secret; use trusted dependencies and a least-privilege registry token.compose.npm.yaml alongside the starter's compose.yaml:
services:
app:
build:
secrets:
- npmrc
secrets:
npmrc:
file: ${NPMRC_PATH:?Set NPMRC_PATH to your npm config file}
Build with NPMRC_PATH="$HOME/.npmrc" docker compose -f compose.yaml -f compose.npm.yaml build. This grants build-time access only, not a runtime secret. Public-package builds should omit the override so no credential file is required.When a project needs a database (Postgres, MySQL, MongoDB), cache (Redis, Memcached), queue (RabbitMQ, Kafka), or any other infrastructure service:
compose.yaml instead of telling the user to install it on the host.brew install postgres, apt install redis, or similar host-level installs for development dependencies.compose.yaml rather than legacy Compose filenames.docker/ subdirectory..env override.USER).Dockerfile that supports both via build stages and build arguments when possible.Dockerfile at the project root (or in a docker/ subdirectory if the project has multiple services).compose.yaml at the project root..dockerignore at the project root, next to the Dockerfile.docker-build-strategies. The starter baseline above (including a non-root USER) still applies here.docker-compose-patterns.docker system prune, docker rm -f, image/network/builder pruning) and a cross-product index of destructive-command guardrails, use docker-destructive-guardrails.references/project-structure.md — Detailed guidance on Docker project file organization, naming conventions, and multi-service layouts.assets/dockerignore-example — A comprehensive .dockerignore for a typical project.assets/compose-dev.yaml — A development-oriented Compose file with Dockerized dependencies.assets/Dockerfile.simple — A basic multi-stage Dockerfile following best practices.scripts/verify-setup.sh — Checks that required files exist in the current directory and validates its compose.yaml. Run it from the project root, with the script path resolved under this skill's directory:
bash "<skill-dir>/scripts/verify-setup.sh" [--help]
Replace <skill-dir> with the absolute path of the folder that contains this SKILL.md; the scripts/ path is relative to that folder, not to the project. Do not change into the skill directory first: the script checks the current directory. If the skill directory cannot be resolved, check that .dockerignore, Dockerfile, and compose.yaml exist in the project root, then run docker compose config --quiet. Exit status is 0 when verification succeeds or help is requested, 1 when required files are missing or the Compose configuration is invalid, and 2 for invalid arguments.checks/verification.md — Detailed verification checklist for manual review.Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database o
---name: docker-project-foundationsdescription: Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly…---# skills/docker-project-foundations/SKILL.md總覽
Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database or cache dependency, or running services without host-level installs. Covers Dockerfile, compose.yaml, and .dockerignore creation with Docker best practices.
常見問題
從發布者下載 skills/docker-project-foundations/SKILL.md,或複製路徑後開啟儲存庫。PlugMCP 只收錄這項技能,不代管檔案。
發布者將它存放在 https://github.com/docker/skills。
Claude、Cursor、Codex 和 Grok Build 可以讀取你從發布者儲存庫加入的 SKILL.md。在聊天中傳送技能的 GitHub 資料夾連結,Grok Bot 就會安裝它。