
Docker Containerization
- 608 installs
- 305 repo stars
- Updated March 4, 2026
- aj-geddes/useful-ai-prompts
docker-containerization is a Claude Code skill that turns applications into production-ready Docker images with multi-stage builds and Compose layouts for developers who need secure, minimal containers for deploy and CI.
About
docker-containerization is a DevOps skill from aj-geddes/useful-ai-prompts that guides agents through optimized Dockerfiles, multi-stage builds, security hardening, and Docker Compose service definitions. The skill includes a table-of-contents reference covering quick-start patterns, image-size reduction, non-root users, and Compose-friendly multi-service layouts for deployment and CI pipelines. Developers reach for docker-containerization when containerizing a new service, shrinking bloated images, or standardizing local and production runtimes before registry push. Outputs follow maintainability and attack-surface reduction practices rather than single-stage dev-only images.
- Multi-stage Dockerfile pattern separating build and slim production runtime (Node 18 Alpine example)
- Security practices including non-root users and minimal copied artifacts
- Reference guides and best-practices sections for maintainable production containers
- Docker Compose setup for local and multi-service development
- CI/CD-oriented container pipelines and microservice packaging workflows
Docker Containerization by the numbers
- 608 all-time installs (skills.sh)
- Ranked #241 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
- Security screen: HIGH risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill docker-containerizationAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 608 |
|---|---|
| repo stars | ★ 305 |
| Security audit | 3 / 3 scanners passed |
| Last updated | March 4, 2026 |
| Repository | aj-geddes/useful-ai-prompts ↗ |
How do you write production Docker multi-stage builds?
Turn an app into production-ready Docker images with multi-stage builds, smaller attack surface, and Compose-friendly layouts for deploy and CI.
Who is it for?
Full-stack and backend developers containerizing services who want multi-stage Dockerfiles, smaller images, and Compose layouts without memorizing hardening checklists.
Skip if: Teams standardizing on Kubernetes Helm charts, serverless-only deploys, or Podman-specific rootless policies not covered by Docker Compose examples.
When should I use this skill?
A developer asks to containerize an app, optimize a Dockerfile, reduce image size, or set up Docker Compose for deployment.
What you get
Dockerfiles, docker-compose.yml service layouts, hardened runtime images, and CI-ready container build instructions.
- Dockerfile
- docker-compose.yml
Files
Docker Containerization
Table of Contents
Overview
Build production-ready Docker containers following best practices for security, performance, and maintainability.
When to Use
- Containerizing applications for deployment
- Creating Dockerfiles for new services
- Optimizing existing container images
- Setting up development environments
- Building CI/CD container pipelines
- Implementing microservices
Quick Start
Minimal working example:
# Multi-stage build for Node.js application
# Stage 1: Build
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
# Stage 2: Production
FROM node:18-alpine
WORKDIR /app
# Copy only production dependencies and built files
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY package*.json ./
# Security: Run as non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
USER nodejs
EXPOSE 3000
CMD ["node", "dist/index.js"]Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Multi-Stage Builds | Multi-Stage Builds |
| Optimization Techniques | Optimization Techniques |
| Security Best Practices | Security Best Practices, Environment Configuration |
| Docker Compose for Multi-Container | Docker Compose for Multi-Container |
| .dockerignore File | .dockerignore File |
| Python | Python (Django/Flask), Java (Spring Boot), Go |
Best Practices
✅ DO
- Use official base images
- Implement multi-stage builds
- Run as non-root user
- Use .dockerignore
- Pin specific versions
- Include health checks
- Scan for vulnerabilities
- Minimize layers
- Use build caching effectively
❌ DON'T
- Use 'latest' tag in production
- Run as root user
- Include secrets in images
- Create unnecessary layers
- Install unnecessary packages
- Ignore security updates
- Store data in containers
Docker Compose for Multi-Container
Docker Compose for Multi-Container
# docker-compose.yml
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile
args:
NODE_ENV: production
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://postgres:password@db:5432/myapp
- REDIS_URL=redis://redis:6379
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
networks:
- app-network
volumes:
- ./uploads:/app/uploads
restart: unless-stopped
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: myapp
POSTGRES_PASSWORD: password
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
- app-network
redis:
image: redis:7-alpine
command: redis-server --appendonly yes
volumes:
- redis-data:/data
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
postgres-data:
redis-data:.dockerignore File
.dockerignore File
# .dockerignore
node_modules
npm-debug.log
dist
.git
.env
.env.local
*.md
!README.md
.DS_Store
coverage
.vscode
.idea
__pycache__
*.pyc
.pytest_cacheMulti-Stage Builds
Multi-Stage Builds
# Multi-stage build for Node.js application
# Stage 1: Build
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
# Stage 2: Production
FROM node:18-alpine
WORKDIR /app
# Copy only production dependencies and built files
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY package*.json ./
# Security: Run as non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
USER nodejs
EXPOSE 3000
CMD ["node", "dist/index.js"]Optimization Techniques
Optimization Techniques
Layer Caching
# ❌ Poor caching - changes in source code invalidate dependency install
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
# ✅ Good caching - dependencies cached separately
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .Minimize Image Size
# ❌ Large image (~800MB)
FROM ubuntu:latest
RUN apt-get update && apt-get install -y python3 python3-pip
# ✅ Minimal image (~50MB)
FROM python:3.11-alpinePython
Python (Django/Flask)
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:app"]Java (Spring Boot)
FROM eclipse-temurin:17-jdk-alpine AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN ./mvnw package -DskipTests
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
RUN addgroup -S spring && adduser -S spring -G spring
USER spring
ENTRYPOINT ["java", "-jar", "app.jar"]Go
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/main .
CMD ["./main"]Security Best Practices
Security Best Practices
FROM node:18-alpine
# Update packages for security patches
RUN apk update && apk upgrade
# Don't run as root
RUN addgroup -g 1001 appgroup && adduser -S -u 1001 -G appgroup appuser
USER appuser
# Use specific versions, not 'latest'
WORKDIR /app
# Scan for vulnerabilities
# Run: docker scan your-image:tagEnvironment Configuration
# Use build arguments for flexibility
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s \
CMD node healthcheck.js || exit 1
# Labels for metadata
LABEL maintainer="team@example.com" \
version="1.0.0" \
description="Production API service"#!/bin/bash
# validate-pipeline.sh - Validate CI/CD pipeline configuration
# Usage: ./validate-pipeline.sh <pipeline_file>
set -euo pipefail
PIPELINE_FILE="${{1:?Usage: $0 <pipeline_file>}}"
echo "Validating pipeline: $PIPELINE_FILE"
# TODO: Add pipeline validation
# - Check YAML/Groovy syntax
# - Verify stage dependencies
# - Check for required stages (build, test, deploy)
# - Validate environment variable references
# - Check for security best practices
echo "Pipeline validation complete."
# CI/CD Pipeline Starter Template
# TODO: Customize for your CI/CD platform (GitHub Actions, GitLab CI, Jenkins, etc.)
name: CI/CD Pipeline
# TODO: Configure triggers
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# TODO: Add build steps
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
# TODO: Add test steps
deploy:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
# TODO: Add deployment steps
- run: echo "Deploy to production"
Related skills
How it compares
Use this skill for Dockerfile and Compose authoring; pair with Kubernetes or Terraform skills when orchestration moves beyond single-host Compose.
FAQ
What does docker-containerization optimize for?
docker-containerization optimizes for production-ready containers: multi-stage builds, minimal image sizes, security best practices, and maintainable Docker Compose services suitable for deployment and CI/CD pipelines.
When should developers invoke docker-containerization?
Developers should invoke docker-containerization when containerizing applications, authoring Dockerfiles, shrinking container images, or defining Docker Compose services before pushing images to a registry.
Is Docker Containerization safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.