Skip to main content
skill CX Codex

docker · oakoss — Claude Code skill: containerization and deployment

Skill for building Docker images, configuring Compose stacks, and preparing containers for production.

MIT 145 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill docker -a claude-code
Open on GitHub

What docker does

The skill covers multi-stage builds, layer caching, docker-compose.yaml, networks, volumes, health checks, and container hardening. The agent writes Dockerfile with separate builder and runtime stages (cuts image size by 80 % or more), copies package-lock.json before source files (dependency layer gets cached), creates a non-root user for the final stage. Inside: pattern table with key decisions, list of common mistakes (installing dev dependencies in production, copying source before npm ci, missing .dockerignore), and references to security, multi-platform builds, and CI caching.

Suited for containerizing applications, dev environments, multi-service stacks, and deploying to ECS, Kubernetes, Fly.io, Railway, Coolify. Works immediately, no FFmpeg, Python, or extra libraries needed. For monorepos, mentions turbo prune --docker (minimal build context from workspace dependencies), but Turborepo is not required — the command is optional.

What it helps with

  • write a Dockerfile with multi-stage build and layer caching
  • configure compose.yaml with services, networks, and volumes
  • add a non-root user and health check
  • build a multi-platform image for ARM and x86
  • exclude secrets from image layers via --mount=type=secret

Example prompts for the agent

  • Write a Dockerfile for a Node.js app with multi-stage build, alpine image, and non-root user
  • Set up compose.yaml for Postgres, Redis, and backend with a named volume for the database
  • Add a health check via curl /health to the Dockerfile and a .dockerignore with node_modules and .git

How to install docker

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill docker -a claude-code

2Manually: put the files in place

~/.claude/skills/docker/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/docker/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about docker

How to install docker in Claude Code?

Run npx skills add oakoss/agent-skills --skill docker -a claude-code. The skill will be installed at ~/.claude/skills/docker/SKILL.md.

What does the docker skill do?

The skill helps write Dockerfile with multi-stage builds, configure Compose stacks, optimize image size, add health checks, and prepare containers for production.

How does multi-stage build differ from a regular build?

Multi-stage build separates builder and production stages: dev dependencies and build artifacts stay in the first stage, only necessary files are copied to the final image. Image size is reduced by 80 % or more.

Source text

SKILL.md · MIT
---
name: docker
description: |
  Docker containerization for development and production. Covers Dockerfiles, multi-stage builds, layer caching, Compose services, networking, volumes, health checks, security hardening, and production deployment patterns.

  Use when writing Dockerfiles, optimizing image size, configuring Compose services, debugging container networking, setting up health checks, hardening containers for production, or troubleshooting build cache issues.
license: MIT
metadata:
  author: oakoss
  version: '1.1'
  source: 'https://docs.docker.com'
user-invocable: false
---

# Docker

## Overview

Docker packages applications into isolated containers that run consistently across environments. A Dockerfile defines the image build steps, Compose orchestrates multi-container services, and production patterns ensure small, secure, performant images.

**When to use:** Containerizing applications, creating reproducible dev environments, orchestrating multi-service stacks, deploying to container platforms (ECS, Kubernetes, Fly.io, Railway, Coolify).

**When NOT to use:** Simple static sites with no backend (use CDN deploy), single-binary CLI tools (distribute the binary), or when the target platform has native buildpacks (Heroku, Vercel) and you don't need container control.

## Quick Reference

| Pattern              | Approach                                       | Key Points                                           |
| -------------------- | ---------------------------------------------- | ---------------------------------------------------- |
| Multi-stage build    | Separate `builder` and `production` stages     | 80%+ image size reduction, no dev deps in production |
| Layer caching        | Copy lockfile first, install, then copy source | Dependency layer cached across builds                |
| Non-root user        | `RUN adduser` + `USER` in final stage          | Never run production containers as root              |
| Health check         | `HEALTHCHECK CMD curl` or node/python check    | Enables orchestrator restart on failure              |
| `.dockerignore`      | Exclude `node_modules`, `.git`, `.env`         | Smaller build context, faster builds                 |
| Compose services     | `compose.yaml` with service definitions        | Dev environment in one command                       |
| Compose override     | `compose.prod.yaml` with production settings   | Environment-specific config without duplication      |
| Named volumes        | `volumes:` in Compose for persistent data      | Survives container recreation                        |
| Build cache mount    | `RUN --mount=type=cache,target=/root/.npm`     | Persistent cache across builds                       |
| Secrets in build     | `RUN --mount=type=secret,id=token`             | Never bake secrets into image layers                 |
| Image pinning        | Pin to major.minor or digest                   | Reproducible builds, avoid surprise breakage         |
| Container networking | Custom bridge networks with service discovery  | Containers resolve each other by service name        |
| Compose watch        | `develop.watch` with sync/rebuild actions      | Live reload without volume mounts                    |
| Init process         | `--init` flag or `tini` entrypoint             | Proper signal handling and zombie reaping            |
| Multi-platform       | `docker buildx build --platform`               | ARM (Apple Silicon, Graviton) + x86 in one image     |
| Monorepo prune       | `turbo prune app --docker`                     | Minimal build context from workspace dependencies    |
| CI layer caching     | `cache-from`/`cache-to` with GHA or registry   | Avoid full rebuilds in CI pipelines                  |
| Debug containers     | `docker exec`, `docker logs`, `dive`           | Inspect running containers and image layers          |

## Common Mistakes

| Mistake                                         | Correct Pattern                                                  |
| ----------------------------------------------- | ---------------------------------------------------------------- |
| Installing dev dependencies in production image | Multi-stage build: install in builder, copy artifacts to runtime |
| Copying source before installing dependencies   | Copy lockfile first, `npm ci`, then copy source for cache reuse  |
| Running as root in production                   | Create non-root user, `USER` directive in final stage            |
| Hardcoding secrets in Dockerfile or ENV         | Use build secrets (`--mount=type=secret`) or runtime env         |
| Using `latest` tag for base images              | Pin to specific version (`node:24-alpine`)                       |
| No `.dockerignore` file                         | Exclude `node_modules`, `.git`, `.env`, build artifacts          |
| Using `npm install` instead of `npm ci`         | `npm ci` for deterministic, lockfile-based installs              |
| HEALTHCHECK missing                             | Add health check for orchestrator integration                    |
| Large base images (`node:24`)                   | Use alpine variants (`node:24-alpine`) for smaller images        |
| Ignoring `.env` file precedence in Compose      | `environment:` in Compose overrides `.env` file values           |
| Building entire monorepo for one service        | Use `turbo prune --docker` for minimal build context             |
| No layer caching in CI                          | Use `cache-from`/`cache-to` with GHA or registry backend         |
| Building only for x86 when deploying to ARM     | Use `docker buildx` with `--platform linux/amd64,linux/arm64`    |

## Delegation

- **Dockerfile review**: Use `Task` agent to audit Dockerfiles for size, security, and caching
- **Compose exploration**: Use `Explore` agent to discover existing Docker configurations
- **Architecture decisions**: Use `Plan` agent for container orchestration strategy

> If the `ci-cd-architecture` skill is available, delegate CI/CD pipeline and deployment strategy to it.
> If the `application-security` skill is available, delegate container security scanning and hardening review to it.

## References

- [Dockerfile patterns: multi-stage builds, layer caching, and image optimization](references/dockerfile-patterns.md)
- [Compose: services, networking, volumes, and environment management](references/compose.md)
- [Security: non-root users, secrets, scanning, and production hardening](references/security.md)
- [Buildx: multi-platform builds for ARM and x86](references/buildx-and-multiplatform.md)
- [CI: GitHub Actions caching, registry push, and automated builds](references/ci-caching.md)
- [Monorepo: Turborepo prune, pnpm workspaces, and selective builds](references/monorepo-builds.md)
- [Debugging: logs, exec, inspect, layer analysis, and network troubleshooting](references/debugging.md)

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for DevOps and infrastructure →

docker by other authors comes first.

docker codewithmukesh Configures Docker containerization for .NET 10 apps with multi-stage builds, non-root user setup, and orchestrator-level health probes. CX Codex +1 4,000installs docker Mindrally Establishes best practices for lean Docker images, multi-stage builds, container security, and Compose workflows. CX Codex +1 1,200installs docker bobmatnyc docker is a Claude Code skill for packaging applications and dependencies into Docker containers. It covers Dockerfiles, image builds, and multi-service setups with Compose. CX Codex +1 1,100installs docker OpenHands Starts the Docker daemon and runs Docker commands inside the agent's container. Use it to build images, start containers and manage them from Claude Code, Cursor or Codex. CX Codex +1 126installs docker ulpi-io Guides your agent to write container setups with multi-stage builds, non-root users, pinned image tags, and strict .dockerignore hygiene. CX Codex +1 122installs docker-expert sickn33 Turns the agent into a Docker expert. It kicks in when a Dockerfile needs rework, a Compose setup fails, or a container behaves oddly. CX Codex +1 27,500installs docker-best-practices JosiahSiegel docker-best-practices — a Docker skill that guides your agent through Dockerfiles, base image choice and production container setup. CX Codex +1 951installs setup-docker-containers davila7 setup-docker-containers sets up Docker for development and production projects, covering multi-stage builds, Compose environments, and container workflows. CX Codex +1 740installs render-docker Render render-docker — a skill that teaches your agent to write Dockerfiles and set up container deploys on Render: builds, private registries, layer caching. CX Codex +1 463installs docker-deployment pluginagentmarketplace docker-deployment — a skill that walks a Node.js app through containerization: Dockerfile, multi-stage builds, Docker Compose and a production-ready image. CX Codex +1 531installs docker-compose-orchestration manutej docker-compose-orchestration — a skill that helps your agent write Docker Compose files for multi-container apps: services, networks, volumes, health checks and startup order. CX Codex +1 3,000installs

From the same set106

The whole set →

Project sponsors

Companies that keep this analytics open