Docker Compose - multi-container deployments
Docker - Overview and how to use it
2 min read
Published Jul 13 2025
Guide Sections
Guide Comments
Docker Compose is a tool for defining and running multi-container Docker applications using a single declarative YAML file. Instead of managing individual containers manually, Compose allows you to orchestrate multiple services like databases, APIs, and frontends with a single command.
With Docker Compose, you can:
- Spin up multiple containers together (
docker compose up
) - Configure volumes, networks, and dependencies
- Easily replicate complex environments locally or in CI/CD
Docker compose file
An example compose file, which is a yml format:
docker-compose.yml
Breakdown:
services:
defines each container (app, db, etc.)build:
builds from a local Dockerfileports:
maps container ports to the hostvolumes:
mounts host folders or named volumesdepends_on:
ensures services start in the correct orderenvironment:
passes env variables to containers
You define network and volumes at the file level, eg:
And then assign them to the service, eg:
Running a compose file
Assumes the compose file is docker-compose.yml
in the current directory, will start a container for each of the services.
This allows you to specify the name of the compose file, if not using the default docker-compose.yml
file.
You can specify the --build
option when running docker compose, to rebuild the images as part of starting the compose.
Viewing compose logs
Viewing logs for all services.
Viewing logs for a specific service.