Home
cd ../playbooks
Developer ToolsIntermediate

Docker Containerization

Containerize applications with production-ready Dockerfiles, Docker Compose configurations, and deployment scripts for Next.js, React, and Node.js projects.

15 minutes
By AI LabsSource
#docker#containers#devops#kubernetes#deployment#nextjs#nodejs

Your Dockerfile is 2 GB because you copied it from Stack Overflow in 2022. It installs dev dependencies in production, runs as root, and rebuilds everything on every code change. 'It works on my machine' is not a deployment strategy.

Who it's for: developers containerizing their first application, teams moving from bare-metal to Docker, DevOps engineers optimizing bloated images, full-stack developers needing production-ready configs, startups setting up Docker Compose for local development

Example

"Containerize our Next.js app for production" → Multi-stage Dockerfile (200 MB vs 2 GB), Docker Compose for local dev with hot reload, production config with health checks, and deployment scripts for AWS ECS and Google Cloud Run

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

Or install from your terminal:
npx ccplaybooks add docker-containerization
# Docker Containerization

## Your Role
You are my DevOps engineer specializing in containerization. Help me create production-ready Docker configurations for web applications, particularly Next.js, React, and Node.js projects.

## Core Capabilities
- Dockerfile generation (production, development, static)
- Docker Compose configurations
- Container management scripts
- Deployment configurations for various platforms

## Decision Tree

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

Containerize your applications with production-ready Docker configurations. Generate optimized Dockerfiles, Docker Compose setups, and deployment scripts for various platforms including Kubernetes, AWS ECS, and Google Cloud Run.


Quick Start

Step 1: Navigate to Your Project

cd ~/your-project

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ./

Step 3: Generate Docker Configuration

claude

Then ask: "Containerize this Next.js app for production"


Supported Configurations

Dockerfile Types

Type Use Case
Production Optimized, multi-stage builds
Development Hot reload, debugging support
Nginx Static Static file serving

Deployment Platforms

  • Kubernetes
  • AWS ECS Fargate
  • Google Cloud Run
  • Azure Container Apps
  • Digital Ocean App Platform

Example Prompts

  • "Create a production Dockerfile for my Next.js app"
  • "Set up Docker Compose for local development"
  • "Generate Kubernetes manifests for deployment"
  • "Create deployment scripts for AWS ECS"

Best Practices Included

Security

  • Non-root user execution
  • Vulnerability scanning setup
  • No hardcoded secrets
  • Minimal base images

Performance

  • Multi-stage builds
  • Layer caching optimization
  • Alpine-based images
  • .dockerignore configuration

Maintainability

  • Version-controlled configs
  • Documented build args
  • DRY principles
  • Clear naming conventions

Sample Dockerfile

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
COPY --from=builder /app/node_modules ./node_modules
COPY --chown=nextjs:nodejs . .
USER nextjs
EXPOSE 3000
CMD ["npm", "start"]

Troubleshooting

Issue Solution
Image too large Use multi-stage builds, Alpine base
Slow builds Optimize layer caching order
Container exits immediately Check CMD and ENTRYPOINT
Changes not reflecting Rebuild without cache

$Related Playbooks

Developer Tools

DevOps Server Manager

Manage servers, Docker containers, VMs, and network infrastructure through Claude Code via SSH. Keep your entire infrastructure documented in markdown files.

15 minutes
Advanced
Developer Tools

Embedding Strategies for RAG

Choose and optimize embedding models for semantic search and RAG — a model comparison table, the query/document prefixes that make-or-break BGE and E5, Matryoshka dimension reduction, four chunking strategies, and a retrieval-quality evaluation harness (precision@k, recall@k, MRR, nDCG@k) so you measure an embedding change instead of guessing at it.

10 minutes
Intermediate
Developer Tools

ETL Pipeline Builder

Design and automate Extract, Transform, Load data pipelines for data integration and analytics

10 minutes
Advanced
Developer Tools

Error Message Explainer — Decode Any Error in Plain English

Paste any error message and get a plain-English explanation, root cause diagnosis, and step-by-step fix. Works with Python, JavaScript, Docker, Git, and any CLI error.

5 minutes
Beginner
Developer Tools

Event Store Design

Design and implement an event store for an event-sourced system — the append-only, per-stream-ordered, globally-positioned model; a technology comparison (EventStoreDB, PostgreSQL, Kafka, DynamoDB, Marten); a complete PostgreSQL schema with the UNIQUE(stream_id, version) constraint that enforces optimistic concurrency; and the snapshot, subscription, and idempotency patterns that keep it correct.

15 minutes
Advanced
Developer Tools

Building Animations in Expo and React Native

A construction discipline for React Native motion: a frequency gate that produces zero lines of code when nothing should animate, a cheapest-tool-that-fits selection table, spring/easing values instead of guesses, and the JS-thread rules that separate 60fps from 20fps on a real device.

10 minutes
Advanced
Developer Tools

7-Phase Feature Development Workflow

Structured feature development that explores the codebase, asks every clarifying question up front, presents multiple architecture options with a recommendation, and runs a three-angle quality review before calling it done.

5 minutes
Intermediate
Developer Tools

Explanatory Coding Mode

Get educational insights about implementation choices and codebase patterns as Claude works — formatted, codebase-specific commentary woven into the session, not a generic tutorial.

2 minutes
Beginner
Developer Tools

Firecrawl Developer Research: Code, Issues & PRs

Investigate library and API bugs, behavior, and version discrepancies using public repository code, issues, and pull requests when the docs aren't enough

10 minutes
Intermediate
Developer Tools

Firecrawl Docs Reader: Answers From Official Documentation

Answer library, SDK, and API questions from current official docs, with version-matched code and citations instead of remembered guesses

10 minutes
Beginner
Developer Tools

Frontend UX Pattern Library

Concrete, research-backed patterns for SaaS dashboards, landing pages, and forms — plus accessibility requirements, Tailwind implementation gotchas, and a pre-delivery checklist that treats accessibility as a launch blocker, not a nice-to-have.

5 minutes
Intermediate
Developer Tools

AI Crawler Access Audit: Who Can Actually Read Your Site

Maps 14 AI crawlers against your robots.txt, meta tags, and HTTP headers, then returns an access score and the exact rules to change

10 minutes
Intermediate

Browse all Developer Tools playbooks →