The Local Development Problem
Docker Compose: Your Full Stack in One File
Define Your Stack
One Command
Why Every Developer Should Know Compose
Advanced Patterns
Compose Watch (New in v2)
Common Stacks
Get Started Your app needs PostgreSQL, Redis, and Elasticsearch. You could install all three on your machine. Or use a cloud service for each. Or fight with Homebrew versions. Or you could define your entire stack in one file and start everything with one command. Docker Compose defines and runs multi-container applications. One YAML file, one command, everything running. PostgreSQL, Redis, and your app — all running. All connected. Stop with Ctrl+C. 1. Reproducible Environments "Works on my machine" is dead. The docker-compose.yml IS the machine. 2. New Team Member Onboarding No 15-page setup guide. No "install PostgreSQL 16, then configure pg_hba.conf, then..." 3. Production-Like Development Your local environment matches production. Same database version, same Redis version, same configuration. Hot Reload for Development Multiple Environments File changes sync to the container. Package.json changes trigger rebuild. Like nodemon but for containers. Next.js + PostgreSQL + Redis
Django + PostgreSQL + Celery + RabbitMQRails + PostgreSQL + Sidekiq + Redis
Express + MongoDB + Redis All definable in one file. All running with one command. Docker Compose is included with Docker Desktop. If you have Docker, you have Compose. Dockerize your data pipelines. 88+ scrapers on Apify. Custom: [email protected] Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse
# -weight: 500;">docker-compose.yml
services: app: build: . ports: - "3000:3000" environment: - DATABASE_URL=postgres://postgres:password@db:5432/myapp - REDIS_URL=redis://redis:6379 depends_on: - db - redis db: image: postgres:16 environment: POSTGRES_PASSWORD: password POSTGRES_DB: myapp volumes: - pgdata:/var/lib/postgresql/data redis: image: redis:7-alpine volumes: pgdata:
# -weight: 500;">docker-compose.yml
services: app: build: . ports: - "3000:3000" environment: - DATABASE_URL=postgres://postgres:password@db:5432/myapp - REDIS_URL=redis://redis:6379 depends_on: - db - redis db: image: postgres:16 environment: POSTGRES_PASSWORD: password POSTGRES_DB: myapp volumes: - pgdata:/var/lib/postgresql/data redis: image: redis:7-alpine volumes: pgdata:
# -weight: 500;">docker-compose.yml
services: app: build: . ports: - "3000:3000" environment: - DATABASE_URL=postgres://postgres:password@db:5432/myapp - REDIS_URL=redis://redis:6379 depends_on: - db - redis db: image: postgres:16 environment: POSTGRES_PASSWORD: password POSTGRES_DB: myapp volumes: - pgdata:/var/lib/postgresql/data redis: image: redis:7-alpine volumes: pgdata:
-weight: 500;">docker compose up
-weight: 500;">docker compose up
-weight: 500;">docker compose up
-weight: 500;">git clone repo
-weight: 500;">docker compose up
# Done. Full dev environment in 2 minutes.
-weight: 500;">git clone repo
-weight: 500;">docker compose up
# Done. Full dev environment in 2 minutes.
-weight: 500;">git clone repo
-weight: 500;">docker compose up
# Done. Full dev environment in 2 minutes.
services: app: build: . volumes: - ./src:/app/src # Code changes reflect instantly command: -weight: 500;">npm run dev
services: app: build: . volumes: - ./src:/app/src # Code changes reflect instantly command: -weight: 500;">npm run dev
services: app: build: . volumes: - ./src:/app/src # Code changes reflect instantly command: -weight: 500;">npm run dev
services: db: image: postgres:16 healthcheck: test: pg_isready -U postgres interval: 5s retries: 5 app: depends_on: db: condition: service_healthy
services: db: image: postgres:16 healthcheck: test: pg_isready -U postgres interval: 5s retries: 5 app: depends_on: db: condition: service_healthy
services: db: image: postgres:16 healthcheck: test: pg_isready -U postgres interval: 5s retries: 5 app: depends_on: db: condition: service_healthy
# Development
-weight: 500;">docker compose up # Testing
-weight: 500;">docker compose -f -weight: 500;">docker-compose.yml -f -weight: 500;">docker-compose.test.yml up # Production
-weight: 500;">docker compose -f -weight: 500;">docker-compose.yml -f -weight: 500;">docker-compose.prod.yml up -d
# Development
-weight: 500;">docker compose up # Testing
-weight: 500;">docker compose -f -weight: 500;">docker-compose.yml -f -weight: 500;">docker-compose.test.yml up # Production
-weight: 500;">docker compose -f -weight: 500;">docker-compose.yml -f -weight: 500;">docker-compose.prod.yml up -d
# Development
-weight: 500;">docker compose up # Testing
-weight: 500;">docker compose -f -weight: 500;">docker-compose.yml -f -weight: 500;">docker-compose.test.yml up # Production
-weight: 500;">docker compose -f -weight: 500;">docker-compose.yml -f -weight: 500;">docker-compose.prod.yml up -d
services: app: develop: watch: - action: sync path: ./src target: /app/src - action: rebuild path: package.json
services: app: develop: watch: - action: sync path: ./src target: /app/src - action: rebuild path: package.json
services: app: develop: watch: - action: sync path: ./src target: /app/src - action: rebuild path: package.json
-weight: 500;">docker compose watch
-weight: 500;">docker compose watch
-weight: 500;">docker compose watch
-weight: 500;">docker compose version
-weight: 500;">docker compose version
-weight: 500;">docker compose version