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.
npx skills add https://github.com/docker/skills --skill 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. See assets/Dockerfile.simple.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.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.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 required files exist and validates compose.yaml. bash scripts/verify-setup.sh [--help]
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.Take docker/docker-project-foundations from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference brew.
Without those the skill loads but fails at the first command.