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.zipInstalls 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.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
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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| docker-patterns (this skill) | 0 | 4mo | Review | Intermediate |
| agent-sandbox | 1 | 6mo | No flags | Intermediate |
| lead-devops | 0 | 1mo | No flags | Intermediate |
| production-dockerfile | 0 | 4mo | Caution | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
agent-sandbox
ruvnet
Agent skill for sandbox - invoke with $agent-sandbox
lead-devops
AbhiGTM19
Assists the user with infrastructure, Docker containerization, and deployment pipelines for the MedVision API.
production-dockerfile
phenobarbital
Generate production-ready Dockerfiles with multi-stage builds, security best practices, and optimization. Use when containerizing Python applications for production deployment.
devops-python-engineer
lek-x
DevOps and Python service delivery for repositories that need build or runtime debugging, CI/CD changes, containerization, deployment automation, infrastructure updates, observability improvements, or backend Python code changes. Use when Codex must act like a DevOps engineer who can also implement
modal
davila7
Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.
senior-computer-vision
davila7
World-class computer vision skill for image/video processing, object detection, segmentation, and visual AI systems. Expertise in PyTorch, OpenCV, YOLO, SAM, diffusion models, and vision transformers. Includes 3D vision, video analysis, real-time processing, and production deployment. Use when building vision AI systems, implementing object detection, training custom vision models, or optimizing inference pipelines.