How to use Docker Compose for multi-service apps
Updated 7/20/2026
Real applications have several parts: a web server, a database, maybe a cache. Docker Compose describes them all in one file and starts them together.
1. The compose.yaml file
services:
web:
image: nginx
ports:
- "80:80"
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
2. Start everything
docker compose up -d
3. Useful commands
docker compose ps # service status
docker compose logs -f # live logs
docker compose down # stop and remove containers
Why Compose
- All configuration in one file, easy to version in git.
- Services reach each other by name (web can access "db").
- Volumes keep data even if you recreate containers, see Docker volumes.
For a full app with a proxy and HTTPS, see How to deploy an app with Docker Compose.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Docker & containers
How to free up disk space used by Docker
Images, stopped containers and orphaned volumes can fill your disk. Here is how to clean them up safely.
Updated 7/20/2026Docker & containersHow to run your own private Docker registry
Host your own Docker images on a private server, without depending on external services.
Updated 7/20/2026Docker & containersDocker security best practices
Run safer containers: non-root users, official images, limited resources and protected secrets.
Updated 7/20/2026