Choose the services you need for your stack
Click Generate to create docker-compose.yml
Download and use in your project
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file (docker-compose.yml) to configure your application's services, networks, and volumes. Then, with a single command, you create and start all the services from your configuration.
Instead of running multiple docker run commands to start each container individually, Docker Compose lets you define your entire application stack in one file. This makes it easy to share development environments, deploy consistent staging environments, and manage complex applications with multiple interconnected services.
version: '3.8'
services:
web:
image: nginx:latest
ports:
- "80:80"
database:
image: postgres:14
environment:
POSTGRES_PASSWORD: example
Click on the service cards to select the containers you need for your application. Common combinations include web server + database + cache (e.g., nginx + PostgreSQL + Redis) or application + database + message queue.
Click "Generate docker-compose.yml" to create your configuration file. The generator includes sensible defaults for ports, volumes, and environment variables. You can customize these values after downloading.
Download the generated docker-compose.yml file and place it in your project root. Run `docker-compose up -d` to start all services. Use `docker-compose down` to stop and remove containers.
Edit the downloaded file to add custom environment variables, change port mappings, add volumes for data persistence, or configure service dependencies. The generated file provides a solid starting point.
Create a complete development environment with database, cache, and other services. Developers can start the entire stack with one command, ensuring everyone has identical development environments.
Define multiple application services that communicate with each other. Docker Compose automatically creates a network for inter-service communication, making it perfect for microservices development.
Use Docker Compose in CI/CD pipelines to spin up test environments. Run integration tests against real databases and services, then tear everything down automatically.
Package your application with all dependencies for easy demos. Share the docker-compose.yml file so others can run your application without complex setup instructions.
Create staging environments that mirror production. Use the same docker-compose.yml with different environment variables to test deployments before going to production.
version: '3.8'
services:
web:
image: nginx:latest
ports:
- "80:80"
depends_on:
- db
db:
image: postgres:14
environment:
POSTGRES_DB: myapp
POSTGRES_PASSWORD: secret
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
version: '3.8'
services:
frontend:
image: node:18
working_dir: /app
volumes:
- ./frontend:/app
ports:
- "3000:3000"
command: npm start
backend:
image: node:18
working_dir: /app
volumes:
- ./backend:/app
ports:
- "4000:4000"
environment:
DATABASE_URL: postgres://db:5432/myapp
depends_on:
- db
db:
image: postgres:14
environment:
POSTGRES_DB: myapp
POSTGRES_PASSWORD: secret
version: '3.8'
services:
app:
image: myapp:latest
ports:
- "8080:8080"
environment:
REDIS_URL: redis://cache:6379
depends_on:
- cache
- db
cache:
image: redis:7-alpine
ports:
- "6379:6379"
db:
image: postgres:14
environment:
POSTGRES_PASSWORD: secret
version: '3.8'
services:
web:
image: nginx:latest
networks:
- frontend
- backend
app:
image: myapp:latest
networks:
- backend
db:
image: postgres:14
networks:
- backend
networks:
frontend:
backend:
version: '3.8'
services:
web:
image: nginx:latest
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 3
db:
image: postgres:14
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
Explore our other DevOps and configuration tools:
Get $200 free DigitalOcean credit or sponsor us on GitHub!