# Docker Compose

> A tool that starts a group of containers. One file and one command do it.

**Field:** Infrastructure  
**Category:** Containers  
**Also known as:** compose.yaml, docker-compose.yml, docker compose up

## Think of it like

It is like a song sheet for a band. One sheet tells every player when to start.

## Definition

Docker Compose runs an app made of several containers from one file. It names the file compose.yaml. The file lists each container, called a service, with its image, ports and volumes. One command starts them all on a shared network. Another command stops and removes them all.

## Example

Emma's app needs a web server, a database and a cache. Her file lists all three. A new teammate starts the whole thing with one command.

## Example code

```yaml
services:
  web:
    image: nginx
    ports:
      - "8080:80"
  cache:
    image: redis
```

Two services in one file. One command starts the web server and the cache together.

## Why it matters

The whole setup lives in one file, so anyone can start it the same way.

## Common mistake

Using Compose to run a big app on many servers. It runs containers on one machine. A fleet of servers needs more.

## Three principles

- **One file.** Every container is listed in compose.yaml.
- **One command.** Up starts them all, down removes them.
- **Shared network.** Services reach each other by name.

## Related terms

- [Docker](https://learn.benibix.com/term/infrastructure/docker)
- [Container](https://learn.benibix.com/term/infrastructure/container)
- [Container Volume](https://learn.benibix.com/term/infrastructure/container-volume)
- [Docker Swarm](https://learn.benibix.com/term/infrastructure/docker-swarm)
- [Container Orchestration](https://learn.benibix.com/term/infrastructure/container-orchestration)
- [Development Environment](https://learn.benibix.com/term/development/development-environment)
- [Container Network](https://learn.benibix.com/term/infrastructure/container-network)

## Told apart from

- [Dockerfile vs Docker Compose](https://learn.benibix.com/compare/dockerfile-vs-docker-compose): People think a compose file replaces the Dockerfile, and it does not. A Dockerfile says how to build one image. A compose file says which containers to run together and how they link. The compose file often points to a Dockerfile to build from. Most apps with two or more containers use both.

![A file named compose.yaml on the left lists two services, web and cache. An arrow labelled docker compose up points to a dashed box on the right, a shared network holding the two containers. Port 8080 leads into the web container, and the cache is found by its name.](https://learn.benibix.com/diagrams/inf-compose.svg)

---

Source: https://learn.benibix.com/term/infrastructure/docker-compose
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
