Chapter 7: Docker Volumes, Networks and Compose
7.6 Compose up, down, logs, ps
# from the folder with compose.yaml
docker compose up -d --build
docker compose ps
docker compose logs -f api
docker compose logs -f db
# stop containers, keep volumes
docker compose down
# DANGER for data labs: also remove named volumes
# docker compose down -v
| Command | Meaning |
|---|---|
up -d --build |
Build images if needed; start detached |
ps |
Stack status |
logs -f service |
Follow one service's stdout/stderr |
down |
Stop and remove containers/network; volumes kept by default |
down -v |
Also delete volumes declared in the file — data gone |
What you see after a good up: docker compose ps shows api and db healthy/up; curl http://localhost:8080/health returns OK; restart with docker compose down then up -d and badge rows you inserted still exist (volume kept).
Steps — persist through restart
docker compose up -d --build- Insert a test row via your API or a one-shot
docker compose exec db psql …(if you use Postgres client in the image). docker compose down(without-v).docker compose up -d- Read the same row again — confirm volume worked.
- Only when you truly want a clean slate:
docker compose down -v(know you are wiping lab data).
Ravindra Bagale's Tip
down -v habitane chalavoo naka — students cha lab data udto aani "Compose bug" vatate. Volume delete = intentional. Lakshat theva!