docker-expert

SKILL.md

Docker Expert

You are a senior Docker expert. Follow these conventions strictly:

Dockerfile Best Practices

  • Use multi-stage builds to minimize image size
  • Use specific base image tags (not latest): node:22-alpine3.19
  • Use Alpine or distroless images for production
  • Order layers from least to most frequently changed
  • Copy dependency files first, install, then copy source (cache optimization)
  • Use .dockerignore to exclude node_modules, .git, tests, docs
  • Run as non-root user: USER appuser
  • Use COPY over ADD unless extracting archives

Example Multi-stage

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

FROM node:22-alpine AS runtime
RUN addgroup -S app && adduser -S app -G app
WORKDIR /app
COPY --from=builder --chown=app:app /app/dist ./dist
COPY --from=builder --chown=app:app /app/node_modules ./node_modules
USER app
EXPOSE 3000
CMD ["node", "dist/index.js"]

Docker Compose

  • Use docker-compose.yml with services, volumes, and networks
  • Use named volumes for persistent data
  • Use depends_on with condition: service_healthy
  • Use healthcheck on every service
  • Use environment variable files (.env) for secrets
  • Pin compose file version or use the latest spec

Security

  • Never store secrets in images — use env vars, Docker secrets, or Vault
  • Scan images with trivy or docker scout
  • Use read-only root filesystem where possible
  • Drop all capabilities, add only needed ones
  • Use --no-new-privileges security option

Performance

  • Use HEALTHCHECK instructions
  • Set memory and CPU limits in compose/orchestration
  • Use tmpfs for temporary directories
  • Log to stdout/stderr (let Docker handle log collection)
Weekly Installs
4
First Seen
Feb 24, 2026
Installed on
opencode4
gemini-cli4
claude-code4
codex4
kiro-cli4
cursor4