agentsclimarketplace

Docker patterns

Skill edjchapman/claude-code-config/skills/docker-patterns

Container build, security, and caching conventions. Use when editing Dockerfiles, Compose files, build contexts, or .dockerignore.From its SKILL.md

Install
npx -y skills add edjchapman/claude-code-config --skill docker-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 8 stars8 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

1.9 KB, as published. Nobody here has run it

Docker Patterns

Multi-Stage Builds

  • Use multi-stage builds to separate build dependencies from runtime
  • Name stages for clarity: FROM node:20 AS builder
  • Copy only build artifacts into the final stage
  • Keep the final image as small as possible (use slim or alpine base images)

Layer Caching

  • Order instructions from least to most frequently changing
  • Copy dependency files (package.json, requirements.txt) before source code
  • Group related RUN commands with && to reduce layers
  • Use .dockerignore to exclude unnecessary files from build context

.dockerignore

  • Always include: .git, node_modules, __pycache__, .env, *.log
  • Mirror .gitignore patterns plus build artifacts
  • Exclude test files and documentation from production images

Security

  • Never run as root -- use USER nonroot or create a dedicated user
  • Don't store secrets in images -- use environment variables or secrets managers
  • Pin base image versions: python:3.12-slim not python:latest
  • Scan images for vulnerabilities with docker scout or trivy
  • Use COPY instead of ADD unless you need tar extraction

Health Checks

  • Always define HEALTHCHECK in production Dockerfiles
  • Use lightweight endpoints (/healthz) that check actual dependencies
  • Set appropriate intervals, timeouts, and retries
  • Health checks should complete quickly (< 5s)

Compose Best Practices

  • Use named volumes for persistent data
  • Define explicit networks for service isolation
  • Use depends_on with health check conditions
  • Use .env files for environment configuration
  • Define resource limits (mem_limit, cpus) for production
  • Use profiles to group services by environment (dev, test, prod)

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.