agentleFS
Jonathan0823Jonathan0823/opencode-config/skills/docker-patterns/SKILL.md

docker-patterns

Skill8 starsChanged 10 months agoMITView on GitHub

Docker best practices, multi-stage builds, container security, Docker Compose orchestration, and deployment patterns. Use when containerizing applications, optimizing Docker images, setting up development environments, or deploying with Docker.

  • Reads credentials
  • Deletes or force-pushes
  • Installs packages

32 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use content-hash-cache-pattern, carrier-relationship-management and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 10 projects that use this

  • InfopibeSkill

    carrier-relationship-management

    Codified expertise for managing carrier portfolios, negotiating freight rates, tracking carrier performance, allocating freight, and maintaining strategic carrier relationships. Informed by transportation managers with 15+ years experience. Includes scorecarding frameworks, RFP processes, market intelligence, and compliance vetting. Use when managing carriers, negotiating rates, evaluating carrier performance, or building freight strategies.

    Also in 8 projects that use this

  • mryeastcodeSkill

    pytorch-patterns

    PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading.

    Also in 7 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 9 projects that use this

  • tpavanipradeepSkill

    ai-regression-testing

    Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code.

    Also in 8 projects that use this

  • +7 more from Infopibe

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Don't include build tools in production

    line 63
  2. Distinctive:

    Run as non-root user

    line 66
  3. Very specific:

    Use specific image tags (not latest)

    line 67
  4. Very specific:

    Use .dockerignore to exclude unnecessary files

    line 74
  5. Distinctive:

    Use this skill when:

    line 154

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Docker Patterns Skill

Overview

This skill provides guidelines for building production-ready Docker containers, multi-stage builds, security hardening, Docker Compose orchestration, and deployment best practices.

Quick Reference

Multi-Stage Build Example

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

# Production stage
FROM node:18-alpine
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
USER nodejs
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
CMD ["node", "dist/main.js"]

Docker Compose Development

version: '3.8'
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - "3000:3000"
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - NODE_ENV=development

Core Principles

1. Multi-Stage Builds

  • Separate build and runtime environments
  • Minimize final image size
  • Don't include build tools in production

2. Security Hardening

  • Run as non-root user
  • Use specific image tags (not latest)
  • Scan images for vulnerabilities
  • Drop unnecessary capabilities

3. Layer Caching

  • Order instructions by change frequency
  • Copy package files before source code
  • Use .dockerignore to exclude unnecessary files

4. Health Checks

  • Implement /health endpoints
  • Configure Docker health checks
  • Set appropriate intervals and timeouts

Language-Specific Examples

See detailed guides in references/:

  • Dockerfile Patterns - Multi-stage builds for Node.js, Python, Go, Rust
  • Docker Compose Patterns - Development, production, and multi-environment setups
  • Container Security - Security hardening, scanning, and best practices
  • Deployment Patterns - Blue-green, rolling updates, Kubernetes

Dockerfile Best Practices

# ✅ DO: Use specific tags
FROM node:18.19.0-alpine3.18

# ✅ DO: Combine RUN commands
RUN apt-get update && \
    apt-get install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

# ✅ DO: Create non-root user
RUN addgroup -g 1001 -S appgroup && \
    adduser -S appuser -u 1001 -G appgroup
USER appuser

# ✅ DO: Copy with ownership
COPY --chown=appuser:appgroup . /app

# ✅ DO: Add health check
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
  CMD wget --quiet --tries=1 --spider http://localhost:3000/health || exit 1

Docker Compose Best Practices

# ✅ DO: Use environment files
services:
  app:
    env_file:
      - .env.production

# ✅ DO: Set resource limits
deploy:
  resources:
    limits:
      cpus: '0.5'
      memory: 512M

# ✅ DO: Configure health checks
healthcheck:
  test: ["CMD", "wget", "--spider", "http://localhost:3000/health"]
  interval: 30s
  timeout: 10s
  retries: 3

Image Scanning

# Using Trivy
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
  aquasec/trivy:latest image myapp:latest

# Using Docker Scout
docker scout cves myapp:latest

# Using Snyk
snyk container test myapp:latest

When to Use This Skill

Use this skill when:

  • Creating Dockerfiles for production applications
  • Setting up development environments with Docker Compose
  • Optimizing image sizes with multi-stage builds
  • Hardening containers for security
  • Setting up health checks and monitoring
  • Managing multiple environments (dev/staging/prod)
  • Implementing CI/CD pipelines with Docker
  • Troubleshooting container issues

Related Skills

  • @ci-cd-pipelines - Continuous integration and deployment with GitHub Actions
  • @security-best-practices - Container security and vulnerability scanning
  • @feature-development - Development workflow
  • @python-patterns - Python-specific patterns
  • @go-conventions - Go-specific patterns
  • @ts-react-nextjs - Node.js patterns

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.