// This skill should be used when containerizing applications with Docker, creating Dockerfiles, docker-compose configurations, or deploying containers to various platforms. Ideal for Next.js, React, Node.js applications requiring containerization for development, production, or CI/CD pipelines. Use this skill when users need Docker configurations, multi-stage builds, container orchestration, or deployment to Kubernetes, ECS, Cloud Run, etc.
| name | docker-containerization |
| description | This skill should be used when containerizing applications with Docker, creating Dockerfiles, docker-compose configurations, or deploying containers to various platforms. Ideal for Next.js, React, Node.js applications requiring containerization for development, production, or CI/CD pipelines. Use this skill when users need Docker configurations, multi-stage builds, container orchestration, or deployment to Kubernetes, ECS, Cloud Run, etc. |
Generate production-ready Docker configurations for modern web applications, particularly Next.js and Node.js projects. This skill provides Dockerfiles, docker-compose setups, bash scripts for container management, and comprehensive deployment guides for various orchestration platforms.
Create optimized Dockerfiles for different environments:
Production (assets/Dockerfile.production):
Development (assets/Dockerfile.development):
Nginx Static (assets/Dockerfile.nginx):
Multi-container orchestration with assets/docker-compose.yml:
docker-build.sh - Build images with comprehensive options:
./docker-build.sh -e prod -t v1.0.0
./docker-build.sh -n my-app --no-cache --platform linux/amd64
docker-run.sh - Run containers with full configuration:
./docker-run.sh -i my-app -t v1.0.0 -d
./docker-run.sh -p 8080:3000 --env-file .env.production
docker-push.sh - Push to registries (Docker Hub, ECR, GCR, ACR):
./docker-push.sh -n my-app -t v1.0.0 --repo username/my-app
./docker-push.sh -r gcr.io/project --repo my-app --also-tag stable
docker-cleanup.sh - Free disk space:
./docker-cleanup.sh --all --dry-run # Preview cleanup
./docker-cleanup.sh --containers --images # Clean specific resources
.dockerignore: Excludes unnecessary files (node_modules, .git, logs)nginx.conf: Production-ready Nginx configuration with compression, caching, security headersdocker-best-practices.md covers:
container-orchestration.md covers deployment to:
Includes configuration examples, commands, auto-scaling setup, and monitoring.
Dockerfile.development (hot reload, all dependencies)Dockerfile.production (minimal, secure, optimized)Dockerfile.nginx (smallest footprint)docker-compose.yml (app + database, microservices)docker.io/username/image123456789012.dkr.ecr.region.amazonaws.com/imagegcr.io/project-id/imageregistry.azurecr.io/imagereferences/container-orchestration.md K8s sectionUser: "Containerize my Next.js app for production"
Steps:
assets/Dockerfile.production to project root as Dockerfileassets/.dockerignore to project root./docker-build.sh -e prod -n my-app -t v1.0.0./docker-run.sh -i my-app -t v1.0.0 -p 3000:3000 -d./docker-push.sh -n my-app -t v1.0.0 --repo username/my-appUser: "Set up Docker Compose for local development"
Steps:
assets/Dockerfile.development and assets/docker-compose.yml to projectdocker-compose up -ddocker-compose logs -f app-devUser: "Deploy my containerized app to Kubernetes"
Steps:
references/container-orchestration.md Kubernetes sectionkubectl apply -f deployment.yamlkubectl get pods && kubectl logs -f deployment/appUser: "Deploy to AWS ECS Fargate"
Steps:
references/container-orchestration.md ECS sectionaws ecs register-task-definition --cli-input-json file://task-def.jsonaws ecs create-service --cluster my-cluster --service-name app --desired-count 3✅ Use multi-stage builds for production
✅ Run as non-root user
✅ Use specific image tags (not latest)
✅ Scan for vulnerabilities
✅ Never hardcode secrets
✅ Implement health checks
✅ Optimize layer caching order ✅ Use Alpine images (~85% smaller) ✅ Enable BuildKit for parallel builds ✅ Set resource limits ✅ Use compression
✅ Add comments for complex steps ✅ Use build arguments for flexibility ✅ Keep Dockerfiles DRY ✅ Version control all configs ✅ Document environment variables
Image too large (>500MB) → Use multi-stage builds, Alpine base, comprehensive .dockerignore
Build is slow → Optimize layer caching, use BuildKit, review dependencies
Container exits immediately
→ Check logs: docker logs container-name
→ Verify CMD/ENTRYPOINT, check port conflicts
Changes not reflecting → Rebuild without cache, check .dockerignore, verify volume mounts
# Build
./docker-build.sh -e prod -t latest
# Run
./docker-run.sh -i app -t latest -d
# Logs
docker logs -f app
# Execute
docker exec -it app sh
# Cleanup
./docker-cleanup.sh --all --dry-run # Preview
./docker-cleanup.sh --all # Execute
- run: |
chmod +x docker-build.sh docker-push.sh
./docker-build.sh -e prod -t ${{ github.sha }}
./docker-push.sh -n app -t ${{ github.sha }} --repo username/app
build:
script:
- chmod +x docker-build.sh
- ./docker-build.sh -e prod -t $CI_COMMIT_SHA
scripts/)Production-ready bash scripts with comprehensive features:
docker-build.sh - Build images (400+ lines, colorized output)docker-run.sh - Run containers (400+ lines, auto conflict resolution)docker-push.sh - Push to registries (multi-registry support)docker-cleanup.sh - Clean resources (dry-run mode, selective cleanup)references/)Detailed documentation loaded as needed:
docker-best-practices.md - Comprehensive Docker best practices (~500 lines)container-orchestration.md - Deployment guides for 6+ platforms (~600 lines)assets/)Ready-to-use templates:
Dockerfile.production - Multi-stage production DockerfileDockerfile.development - Development DockerfileDockerfile.nginx - Static export with Nginxdocker-compose.yml - Multi-container orchestration.dockerignore - Optimized exclusion rulesnginx.conf - Production Nginx configuration