docker compose watch syncs, rebuilds or restarts services when source files change
Answer: Add a develop.watch list to a service and run docker compose watch (or docker compose up --watch). Each rule names a path and an action: sync, rebuild or sync+restart. The develop section is available with Docker Compose version 2.22.0 and later.
Example
services:
web:
build: .
develop:
watch:
- action: sync
path: ./web
target: /src/web
ignore:
- node_modules/
- action: rebuild
path: package.json
Actions
sync: Compose makes sure changes to files on your host automatically match the corresponding files within the service container. It suits frameworks with "Hot Reload". For many development use cases, sync rules can replace bind mounts.rebuild: Compose automatically builds a new image with BuildKit and replaces the running service container. Rebuild is ideal for compiled languages.sync+restart: Compose synchronizes your changes with the service containers and restarts them. Use it when a config file changes: the image need not be rebuilt, only the main process restarted.
Path rules
- Paths are relative to the project directory (ignore file patterns excepted).
- Watching of directories is recursive.
.dockerignorerules apply; use theignoreoption to define additional paths to be ignored..gitdirectories and temporary/backup files for common IDEs are ignored automatically.- In a Node.js project, it's not recommended to sync the
node_modules/path.
The container user must be able to write to the target path so it can update files.
See also
Claims
- id: C1 claim: sync matches host changes into the service container. source: S1 evidence: "Compose makes sure any changes made to files on your host automatically match"
- id: C2 claim: rebuild builds a new image and replaces the running container. source: S1 evidence: "Compose automatically builds a new image with BuildKit and replaces the running service container"
- id: C3 claim: .git directories are ignored automatically. source: S1 evidence: ".git directories are ignored automatically"
- id: C4 claim: Develop requires Docker Compose 2.22.0 or later. source: S2 evidence: "It is available with Docker Compose version 2.22.0 and later."
Sources
- [S1] Use Compose Watch. Docker docs (Compose how-tos). https://docs.docker.com/compose/how-tos/file-watch/ . License: Apache-2.0. Accessed 2026-11-18.
- [S2] Compose Develop Specification. Docker docs (reference). https://docs.docker.com/reference/compose-file/develop/ . License: Apache-2.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs (Compose how-tos), Use Compose Watch; Docker docs (reference), Compose Develop Specification. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker docs (Compose how-tos), Use Compose Watch; Docker docs (reference), Compose Develop Specification. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "docker compose watch syncs, rebuilds or restarts services when source files change." iinventedlight Library, iil:note:3mrb3dgb, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-compose-watch/. License: CC-BY-4.0.
@misc{iil_note_3mrb3dgb,
author = {{iinventedlight}},
title = {{docker compose watch syncs, rebuilds or restarts services when source files change}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/docker-compose-watch/},
note = {Permanent ID iil:note:3mrb3dgb. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- docker-compose-watch.table.json (table; CC-BY-4.0)
- docker-compose-watch.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-compose-watch.md.