containerization-patterns

Applies Docker and Docker Compose best practices for containerizing applications across dev and production environments.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/juanjo-zurich/juarvis-v4 --skill containerization-patterns-juanjo-zurich
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: containerization-patterns
Source: https://github.com/juanjo-zurich/juarvis-v4/tree/main/plugins/frontend/skills/containerization-patterns
Command: npx skills add https://github.com/juanjo-zurich/juarvis-v4 --skill containerization-patterns-juanjo-zurich

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Dockerfiles and Docker Compose configurations from scratch often leads to bloated images, security risks like root processes, leaked secrets, and fragile service orchestration between development and production environments. ## Core Features & Use Cases - Dockerfile Best Practices: Multi-stage builds, non-root users, layer caching optimization, .dockerignore usage, and pinned base image versions. - Docker Compose Patterns: Service isolation, bind mounts for hot-reloading, healthcheck-based dependencies, private networks, and environment variable management via .env files. - Environment Separation: Distinct configurations for development (volumes, exposed ports, debug tools) versus production (resource limits, restart policies, structured logging). - Use Case: When containerizing a web application with a database, use this Skill to generate a multi-stage Dockerfile with a non-root user and a Compose file where the app waits for the database healthcheck before starting. ## Quick Start Ask the AI to write a production-ready Dockerfile and Docker Compose setup for your application following containerization best practices.

Frequently Asked Questions about containerization-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Dockerfile following best practices?▼

Use multi-stage builds to separate build dependencies from the runtime, run the process as a non-root user, order commands for optimal layer caching, pin base images to specific versions like node:20.11.0-alpine3.19, and add a .dockerignore file excluding node_modules and .env.

How do I make Docker Compose wait for a database to be ready?▼

Use depends_on with the condition service_healthy instead of a plain depends_on. Define a healthcheck on the database container so dependent services only start once the database is actually ready to accept connections.

Should development and production use the same Docker Compose file?▼

No. Use docker-compose.yml for development with bind mounts, exposed ports, and debug tools, and a separate docker-compose.prod.yml for production with no local code volumes, resource limits, restart policies, and structured logging.

Why should containers not run as root?▼

Running the main process as root increases the attack surface if the container is compromised. Create a dedicated user like appuser and switch to it with the USER directive in the Dockerfile after completing installation steps.

How do I handle secrets in Docker Compose?▼

Pass dynamic values through an .env file referenced with env_file instead of hardcoding credentials in the compose file. Also exclude .env in .dockerignore so secrets are never copied into image layers.