पाठ 23 / 25
A Smooth Development Workflow
Fast feedback loops.
watch, logs, exec, run
For development: bind-mount source code or use Compose Watch (develop.watch with docker compose watch) to sync files and rebuild on changes; follow logs per service; open shells with exec; run tests and migrations as one-off run --rm commands; and seed data with scripts. Make the first-time setup a single command (copy .env.example, create secrets, up -d) and document it.
Use Compose well
Smooth development workflows, knowing when to move beyond Compose, and a review checklist.
Compose Watch configuration (sketch)
File sync and rebuild rules for the API; check the Compose docs for your version. Not run here.
services:
api:
build: ./api
develop:
watch:
- action: sync # copy changed source files into the container
path: ./api/src
target: /app/src
- action: rebuild # rebuild the image when dependencies change
path: ./api/package.jsonOne command to start
A make up or npm run dev wrapper that prepares .env and secrets and runs Compose removes onboarding friction.
त्वरित जाँच: What is docker compose run --rm useful for?
- One-off tasks like migrations or tests in a temporary container
- Deleting volumes
- Publishing ports permanently
- Building the Compose binary
Answer
One-off tasks like migrations or tests in a temporary container — Run and clean up.