Live Development Workflows with docker compose watch (Sync & Rebuild)
Use compose watch to sync files and rebuild services during local development.
In plain words
Use sync for interpreter/source files whose process can reload, and rebuild for compiled dependencies or Dockerfile/base changes.
Think of it like…
watch is a conveyor belt with two lanes: small editable drawings ride into the existing station, while a new machine part sends the whole station back through the workshop.
Where you’ve seen it
In practice, develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] } is the concrete move for this job: use compose watch to sync files and rebuild services during local development. The release is not accepted until run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events confirms the result.
Words you’ll hear
- watch
- The implementation control in
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }for use compose watch to sync files and rebuild services during local development. - Sync
- The result to observe with
run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events, rather than infer from a successful command alone. - Rebuild
- The production boundary exposed when declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild.
Visual diagram
Theory & deep dive
watch control path
The concrete mechanism is develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }. The observable result is run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events; if those disagree, inspect the runtime evidence before changing unrelated settings.
Use compose watch to sync files and rebuild services during local development. Keep watch, Sync and Rebuild in the same deployment record so the intent and the observed state cannot drift apart.
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }
run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events, not with command success alone.Rebuild failure boundary
Syncing dependencies, locks or generated artifacts can leave an app in a mixed state. File system events through Docker Desktop/WSL mounts and process reload support differ, so watch needs an explicit action matrix and ignore list. The narrow failure to design for is declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild.
Accept this compromise explicitly: Watch shortens one-host development loops; a full rebuild remains the production fidelity test. The controlled check-run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events-also identifies the point where a different design is safer.
Exercise this failure safely: declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: Syncing dependencies, locks or generated artifacts can leave an app in a mixed state. File system events through Docker Desktop/WSL mounts and process reload support differ, so watch needs an explicit action matrix and ignore list.
- Intent
- watch
When to use it & trade-offs
What it is
compose watch attaches development actions to services: sync copies changed files into a path in a container, rebuild runs a Docker build and replaces the image, and rebuild-or-sync can fall back when action or ignore rules change.
Why it matters: Syncing dependencies, locks or generated artifacts can leave an app in a mixed state. File system events through Docker Desktop/WSL mounts and process reload support differ, so watch needs an explicit action matrix and ignore list.
When to reach for it
- The fit is strongest for this job: use compose watch to sync files and rebuild services during local development. Pair it with
run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild eventsin the runbook. - Production watch changes should make Sync observable through
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }, rather than trusting the runtime default. - Keep a rollback example for the case where declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild.
When to avoid or be careful
- Do not accept command success while the system can still fail by declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild.
- Avoid erasing Rebuild protection merely to dodge this cost: “Watch shortens one-host development loops; a full rebuild remains the production fidelity test”.
- Do not replace the evidence path-
run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events-with a screenshot or a mutable tag.
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }: practical choices
Strengths: compose watch attaches development actions to services: sync copies changed files into a path in a container, rebuild runs a Docker build and replaces the image, and rebuild-or-sync can fall back when action or ignore rules change.
Watch out: Watch shortens one-host development loops; a full rebuild remains the production fidelity test.
Strengths: It can begin with develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] } and fewer surrounding controls.
Watch out: It silently accepts declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild, which makes the result hard to reproduce after promotion.
Strengths: Syncing dependencies, locks or generated artifacts can leave an app in a mixed state. File system events through Docker Desktop/WSL mounts and process reload support differ, so watch needs an explicit action matrix and ignore list.
Watch out: The platform adds an ownership and debugging layer; retain run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events as the direct check.
Interview signals & numbers to know
When this topic comes up
- develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }
- run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events
- Failure signature: declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild
- Trade-off: Watch shortens one-host development loops; a full rebuild remains the production fidelity test.
Benchmarks & rules of thumb
- 2 main actions
- sync and rebuild
- 1 process reload path
- required for synced code to become live
- 0 production promotion
- from a watch-only edit that never builds a release artifact
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }as proof and skippingrun docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events. - Declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild
- Optimizing watch without accepting that watch shortens one-host development loops; a full rebuild remains the production fidelity test.
Likely interviewer follow-ups
- Why does
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }address watch here rather than through application code? - How would you distinguish healthy Sync from the failure “declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild” using
run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events? - When would this trade-off-“Watch shortens one-host development loops; a full rebuild remains the production fidelity test”-justify a different Rebuild design?
develop: { watch: [{ action: sync, path: ./src, target: /app/src }, { action: rebuild, path: package-lock.json }] }-and one proof-run docker compose watch, change one source file and the lockfile separately, then observe sync versus rebuild events. Then name the boundary: declaring sync for native modules or lockfiles and expecting a different binary ABI to become valid without rebuild.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Live Development Workflows with docker compose watch (Sync & Rebuild) with generative AI interview Q&A and hands-on practice.