Script Valley
Docker: Complete Course
Docker ComposeLesson 4.1

What is Docker Compose and when to use it

docker-compose.yml, services, Compose CLI, single-host orchestration, Compose vs Kubernetes, compose up, compose down

Running Multi-Container Apps Without Typing 10 Commands

Docker Compose service orchestration

Docker Compose is a tool for defining and running multi-container applications using a single YAML file. Instead of running three docker run commands with a dozen flags each, you write them once in docker-compose.yml and run docker compose up.

Core Compose Commands

# Start all services (build images if needed, detach)
docker compose up -d

# View logs for all services (or one)
docker compose logs -f
docker compose logs -f api

# Stop and remove containers, networks
docker compose down

# Stop and also remove named volumes
docker compose down -v

When to Use Compose

Compose is for single-host development and testing. If you need to run your app stack locally, Compose is the right tool. For production deployments across multiple machines, you would use Kubernetes or Docker Swarm — but Compose files are often the starting point for those too.

Docker Compose v2 is included in Docker Desktop and as a plugin on Linux (docker compose with a space). The older standalone docker-compose (with a hyphen) is deprecated. Always use docker compose.

Up next

Writing your first docker-compose.yml file

Sign in to track progress