docker-containers
Master Docker with containers, images, multi-stage builds, Docker Compose, networking, and production-ready containerization.
When & Why to Use This Skill
This Claude skill empowers developers and DevOps engineers to master Docker containerization and orchestration. It provides comprehensive guidance on creating efficient multi-stage Dockerfiles, managing complex multi-container applications with Docker Compose, and implementing production-grade security and performance best practices. By standardizing the containerization workflow, it ensures consistent environments across development, testing, and production, significantly reducing deployment friction.
Use Cases
- Optimizing Docker Images: Implementing multi-stage builds to significantly reduce image size, minimize attack surfaces, and improve deployment speed.
- Local Development Orchestration: Using Docker Compose to spin up full-stack environments including databases, caches, and application servers with a single command to ensure 'it works on my machine'.
- Production Readiness: Applying security best practices such as non-root user execution, alpine base images, and health checks for robust and secure cloud deployments.
- CI/CD Pipeline Integration: Standardizing build and test environments to ensure consistent behavior across automated pipelines and various cloud infrastructure providers.
| name | docker-containers |
|---|---|
| description | Master Docker with containers, images, multi-stage builds, Docker Compose, networking, and production-ready containerization. |
Docker Containerization
Build and deploy applications with Docker containers, multi-stage builds, and production-ready configurations.
Core Patterns
Dockerfile
# Multi-stage build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY package*.json ./
RUN npm ci --production
EXPOSE 3000
CMD ["node", "dist/index.js"]
Docker Compose
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgres://user:pass@db:5432/myapp
depends_on:
- db
- redis
db:
image: postgres:16-alpine
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=pass
- POSTGRES_DB=myapp
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
postgres_data:
Build and Run
# Build image
docker build -t myapp:latest .
# Run container
docker run -d -p 3000:3000 --name myapp myapp:latest
# View logs
docker logs -f myapp
# Execute command in container
docker exec -it myapp sh
Best Practices
- Use multi-stage builds
- Minimize layer count
- Use .dockerignore
- Run as non-root user
- Use alpine images
- Implement health checks
- Use Docker secrets
- Tag images properly