Compose files
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
describe a multi-service environment in one file.
Planned topics
- Compose runs several containers together from
compose.yaml; one command starts or stops them all. - Each entry under
services:is a container:imageorbuild,ports,environment,volumes. - Compose creates a network for the project; services reach each other by service name.
- Named volumes go under
volumes:. - Commands:
docker compose up -d,ps,logs -f,down(add-vto delete volumes).
Draft outline details
Demonstration
services:
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: dev
volumes: [pgdata:/var/lib/postgresql/data]
app:
build: .
ports: ["8080:8080"]
volumes:
pgdata:Check your understanding
What does docker compose down -v do beyond down?
Show answer
It also deletes the named volumes and their data.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.