Skip to content
BENIBIX Learn

Docker Compose

Infrastructure📦 ContainersRuntimes and Tools

Also known as compose.yaml, docker-compose.yml, docker compose up

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

Think of it like

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

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.

Why it matters

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

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 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.
One file and one command. Both containers start together and can talk on their own network.

Common mistake

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

Key takeaways

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

Compare