The Desi Architect
Notes / Docker Sandboxes / Docker Compose in Practice: Healthchecks, Restarts & Volumes
Docker Sandboxes · Tier 0: Start Here · Lab 02

Docker Compose in Practice: Healthchecks, Restarts & Volumes

Go beyond up and down. Check that a service is really ready, watch Docker restart a container that crashes, prove that a volume keeps your data when the container is replaced, and learn what down and down -v each delete.

Time40 minutes
StackWeb on port 18080Ports 18080
MemoryAbout 50 MB
Before thisLab 01Docker Compose Basics
Verified runWindows, Mac, LinuxBash and PowerShell
  1. 1PrepareWhat you will learn
  2. 2PredictGuess before you run
  3. 3RunStep by step
  4. 4ObserveWhat you should see
  5. 5Break itChange one thing
  6. 6Clean upLeave nothing running
On this page
  1. 00 / What You Will Learn
  2. 01 / Why It Matters
  3. 02 / What We Are Building
  4. 03 / Words You Need
  5. 04 / Predict First
  6. 05 / Step by Step
  7. 06 / What You Should See
  8. 07 / Look Inside
  9. 08 / Break It, Fix It
  10. 09 / In Real Projects
  11. 10 / Interview Corner
  12. 11 / Clean Up

00 /What You Will Learn

By the end you will be able to
  • Tell running from healthy, and write a healthcheck.
  • Explain what restart: unless-stopped does when an app crashes.
  • Prove that data in a volume survives when a container is deleted and recreated.
  • Say exactly what docker compose down keeps and what down -v deletes.
  • Explain why containers reach each other by service name, never by IP address.

Before you start

Finish Lab 01 (Docker Compose Basics) first. You should be comfortable with docker compose up -d, ps, logs and with the idea of a service name. Docker Desktop must be running.