Multi-Container Apps with Docker Compose
Compose a three-service stack from scratch: a web tier, a publisher sharing a named volume, and a monitor doing service-discovery health checks on a custom network — then scale it and tear it down without losing data.
- Advanced
- 45 min
- Docker
- Compose
- Orchestration
- Networking
Overview
Single containers are easy; real applications are stacks. In this lab you compose three cooperating services from an empty directory: a web tier serving from a named volume, a publisher (sidecar) that writes content into that same volume, and a monitor that finds the web service by name over a custom network.
You'll declare it all in docker-compose.yml, bring it up, scale the publisher with a single flag, and tear it down without destroying your data — the difference between down and down -v that has saved (and ended) production databases. This is the orchestration foundation that Kubernetes later generalizes.
What you will learn
- Declare services, named volumes, and networks in a
docker-compose.yml - Share one named volume between two containers (the sidecar pattern)
- Use Compose's DNS-based service discovery to reach a service by name
- Scale a service to multiple replicas with
--scale - Tear a stack down while preserving named-volume data
Before you start
- The earlier Docker labs first, or equivalent Docker fluency
- Comfortable editing YAML (indentation matters)
- Linux shell +
sudo
Tasks
- 01Define the web service with a named volume
- 02Add a publisher that shares the volume
- 03Service discovery on a custom network
- 04Scale the publisher
- 05Tear down without losing data