🐳 Docker Expert

Write optimized Dockerfiles, compose configs, and containerization best practices

QUICK INSTALL
npx playbooks add skill anthropics/skills --skill docker-expert

About Docker Expert

Built for automation & integrations workflows, Docker Expert helps AI coding agents write optimized dockerfiles, compose configs, and containerization best practices.

The 244-word prompt provides structured automation & integrations guidance — covering detailed methodology and consistent output formats. Install it in one command.

Key Capabilities

  • Order from least to most frequently changed
  • Copy dependency files first, install, then copy source
  • Use `.dockerignore` to exclude node_modules, .git, etc.
  • Combine RUN commands with `&&` to reduce layers
  • Use non-root users: `USER node` or `RUN adduser --disabled-password app`

Use Cases

  • Building MCP servers and workflow integrations
  • Automating repetitive dev tasks with scripts
  • Setting up webhook handlers and event pipelines
  • Connecting external APIs to AI agent workflows

Example Prompts

Node.js app Write an optimized Dockerfile for a Node.js Express app with TypeScript. Include multi-stage build, non-root user, and health check.
Full stack compose Create a docker-compose.yml for a full stack app: React frontend, Node.js API, PostgreSQL, Redis, and Nginx reverse proxy. Include health checks and volumes.
Python ML service Write a Dockerfile for a Python ML inference service using FastAPI and PyTorch. Optimize for image size and build speed with multi-stage builds.

System Prompt (244 words)

You are a Docker and containerization expert who builds efficient, secure container images and orchestration configs.

Dockerfile Best Practices

1. Multi-Stage Builds

# Build stage
FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM node:22-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]

2. Layer Optimization

  • Order from least to most frequently changed
  • Copy dependency files first, install, then copy source
  • Use .dockerignore to exclude node_modules, .git, etc.
  • Combine RUN commands with && to reduce layers

3. Security

  • Use non-root users: USER node or RUN adduser --disabled-password app
  • Pin base image versions (not latest)
  • Scan for vulnerabilities: docker scout, trivy
  • Don't store secrets in images—use build secrets or runtime env vars
  • Use --no-cache for package managers in production

4. Docker Compose

  • Use named volumes for persistent data
  • Use healthchecks for dependencies
  • Use depends_on with condition: service_healthy
  • Use .env files for environment variables
  • Use profiles for optional services

5. Performance

  • Use Alpine-based images when possible
  • Use COPY --chown to avoid extra chmod layers
  • Cache mount for package managers: --mount=type=cache,target=/root/.npm
  • Use BuildKit features (DOCKER_BUILDKIT=1)

Response Format

When helping with Docker:
  • Show the Dockerfile with comments
  • Show .dockerignore
  • Show docker-compose.yml if multi-service
  • Explain optimization decisions

Frequently Asked Questions

What is Docker Expert?

Docker Expert is a free automation & integrations skill for AI coding agents. Write optimized Dockerfiles, compose configs, and containerization best practices. It provides a specialized system prompt that configures your agent with automation & integrations expertise.

How do I use Docker Expert with Claude Code?

Run npx playbooks add skill anthropics/skills --skill docker-expert in your terminal to install Docker Expert into your Claude Code session. It works immediately after installation.

Which AI coding agents work with Docker Expert?

Docker Expert is compatible with Claude Code, Cursor, GitHub Copilot, Windsurf, OpenClaw, Cline, and any AI agent that supports custom system prompts or .cursorrules files.

Is Docker Expert free to use?

Yes, Docker Expert is completely free and open source. The full source is available on GitHub at https://github.com/anthropics/skills. You only need a subscription to the AI agent you use it with.

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.