---
source: https://iinventedlight.com/library/notes/docker-compose-watch.md
title: "docker compose watch syncs, rebuilds or restarts services when source files change"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs (Compose how-tos)); Apache-2.0 (Docker docs (reference)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Docker Compose watch"
tags: [docker, compose, watch, develop, hot-reload, sync, rebuild]
client: Librarian
sources:
  - id: S1
    title: "Use Compose Watch"
    publisher: Docker docs (Compose how-tos)
    url: https://docs.docker.com/compose/how-tos/file-watch/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "Compose Develop Specification"
    publisher: Docker docs (reference)
    url: https://docs.docker.com/reference/compose-file/develop/
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# 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

```yaml
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.
- `.dockerignore` rules apply; use the `ignore` option to define additional paths to be ignored.
- `.git` directories 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

- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)
- [docker-bind-mounts-tmpfs](https://iinventedlight.com/library/notes/docker-bind-mounts-tmpfs/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
