Compose applications

Build a fast development loop

Use targeted rebuilds, logs, exec, and cleanup commands without destroying useful development data by accident.

8 minute lesson

~~~

Compose is most useful when everyday commands are predictable enough to become muscle memory.

up --build reconciles the running project with its configuration, logs -f follows output, and exec runs a command in an existing service. down removes project containers and networks; down -v also removes named volumes and their data.

docker compose up --build -d
docker compose logs -f api
docker compose exec api node --version
docker compose ps
docker compose down

Know which artifact each edit invalidates. A bind-mounted source change may need only an application reload. A Dockerfile or dependency change needs an image rebuild. A configuration change may need a container recreation even when the image is unchanged. Use docker compose up -d --build api to target the service, then inspect docker compose ps instead of assuming it was replaced.

Treat down -v as destructive: it removes the project’s named volumes and cannot be undone without a backup. Ordinary down is the safer reset when you want to preserve database state. When debugging, change one layer at a time and keep the last working image tag so you can distinguish an application regression from damaged development data.

Change the API response, rebuild only the API service, and confirm the database data survives ordinary down and up commands.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →