DO

docker-patterns

Implement optimized Docker patterns for containerized Python applications.

Install

mkdir -p .claude/skills/docker-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16221" && unzip -o skill.zip -d .claude/skills/docker-patterns && rm skill.zip

Installs to .claude/skills/docker-patterns

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Docker and Docker Compose patterns for Python development, container security, networking, and multi-service orchestration.
123 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Dockerize Python applications with multi-stage Dockerfiles
  • Set up Docker Compose for multi-service Python stacks
  • Implement container security best practices
  • Manage Docker Compose services with common commands
  • Configure health checks for Dockerized services

How it works

The skill provides multi-stage Dockerfile examples for Python applications and Docker Compose configurations for orchestrating services like databases and Redis. It also includes security recommendations and common Docker commands.

Inputs & outputs

You give it
Python application code
You get back
optimized Dockerfile, Docker Compose YAML, and secure container configurations

When to use docker-patterns

  • Optimize python dockerfile
  • Setup docker compose
  • Containerize fastapi app
  • Implement healthchecks

About this skill

Docker Patterns for Python

Docker and Docker Compose best practices for Python/Django/FastAPI projects.

When to Activate

  • Setting up Docker Compose for local development
  • Designing multi-container architectures
  • Dockerizing Python applications

Python Dockerfile (Multi-Stage)

FROM python:3.12-slim AS builder
WORKDIR /app
RUN pip install --no-cache-dir uv
COPY requirements.txt .
RUN uv pip install --system --no-cache -r requirements.txt

FROM python:3.12-slim AS runner
WORKDIR /app
RUN useradd -r -u 1001 appuser
USER appuser
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY . .
ENV PYTHONUNBUFFERED=1
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/')" || exit 1
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "4"]

Docker Compose for Python Stack

services:
  app:
    build:
      context: .
      target: runner
    ports:
      - "8000:8000"
    volumes:
      - .:/app
    environment:
      - DATABASE_URL=postgres://postgres:postgres@db:5432/app_dev
      - REDIS_URL=redis://redis:6379/0
      - DJANGO_SETTINGS_MODULE=config.settings.development
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    command: python manage.py runserver 0.0.0.0:8000

  db:
    image: postgres:16-alpine
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: app_dev
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 3s
      retries: 5

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

  celery:
    build: .
    command: celery -A config worker -l info
    volumes:
      - .:/app
    environment:
      - DATABASE_URL=postgres://postgres:postgres@db:5432/app_dev
      - REDIS_URL=redis://redis:6379/0
    depends_on:
      - db
      - redis

  celery-beat:
    build: .
    command: celery -A config beat -l info
    volumes:
      - .:/app
    depends_on:
      - redis

volumes:
  pgdata:

Security

services:
  app:
    security_opt:
      - no-new-privileges:true
    read_only: true
    tmpfs:
      - /tmp
    cap_drop:
      - ALL

Common Commands

docker compose up                    # Start
docker compose logs -f app           # Follow logs
docker compose exec app python manage.py shell  # Django shell
docker compose exec db psql -U postgres          # Postgres shell
docker compose down -v               # Stop and remove volumes

When not to use it

  • When Dockerizing applications in languages other than Python
  • When not using Docker Compose for multi-service orchestration

Limitations

  • Primarily focused on Python development
  • Examples are specific to Django/FastAPI projects
  • Security options are limited to those shown in the example

How it compares

This skill offers specific Docker and Docker Compose patterns tailored for Python applications, including multi-stage builds and security configurations, which differs from generic containerization approaches.

Compared to similar skills

docker-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
docker-patterns (this skill)04moReviewIntermediate
agent-sandbox16moNo flagsIntermediate
lead-devops01moNo flagsIntermediate
production-dockerfile04moCautionIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry