What is Compose watch and how does it improve developer experience?
Why Interviewers Ask This
Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.
Answer
Docker Compose Watch (introduced in Docker Compose 2.22 / Docker Desktop 4.24) is a developer experience feature that automatically syncs file changes from the host into running containers and can trigger service rebuilds — providing a live development loop without manually restarting services. Configure in compose.yml under each service: develop:\n watch:\n - action: sync\n path: ./src\n target: /app/src\n - action: rebuild\n path: ./package.json\n - action: sync+restart\n path: ./config\n target: /app/config. Actions: sync — copy changed files into the running container (like a live bind mount but more targeted); rebuild — trigger a docker compose build + recreate when specified files change (e.g., package.json changes → rebuild image with new dependencies); sync+restart — sync files then restart the container. Start with watch: docker compose watch (or docker compose up --watch). Benefits over bind mounts: (1) Works correctly on macOS (bind mounts on Mac suffer from performance and inotify issues); (2) More explicit control over what gets synced; (3) Can trigger rebuilds for dependency changes without syncing node_modules back; (4) Compatible with native file watchers in frameworks (nodemon, webpack HMR). Requires Docker Compose spec v2+ and BuildKit.
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Docker candidates.
More Docker Questions
View all →- Advanced What is containerd and how does it relate to Docker?
- Advanced What are Linux namespaces and cgroups, and how do they enable containers?
- Advanced What is overlay2 storage driver and how does it work?
- Advanced What is Docker Buildx and multi-platform builds?
- Advanced What is Docker networking at a deep level (iptables, veth pairs)?