Skip to content

fix(watch): exclude Dockerfile and compose files from the sync loop - #14217

Open
Orivital wants to merge 1 commit into
docker:mainfrom
Orivital:fix/watch-exclude-compose-files-from-sync-loop
Open

fix(watch): exclude Dockerfile and compose files from the sync loop#14217
Orivital wants to merge 1 commit into
docker:mainfrom
Orivital:fix/watch-exclude-compose-files-from-sync-loop

Conversation

@Orivital

@Orivital Orivital commented Sep 12, 2026

Copy link
Copy Markdown

What I did

#14117 restored the initialSync exclusion so docker compose watch does not copy the Dockerfile or compose files into the container on first sync. That PR called out that the continuous loop (getWatchRules) never had the same ignore, and that it would need a differently-anchored matcher because it matches absolute host paths rather than basenames.

Without that, a develop.watch sync on the project root still copies Dockerfile / compose.yaml (and a custom build.dockerfile) into the container when those files change after watch has started.

Shared the ignore as dockerFileIgnoreMatcher with **/-anchored patterns so it works for both initialSync's basenames and the watch loop's full paths. Applied it only to copy actions (sync, sync+restart, sync+exec) so a rebuild trigger on the same tree still fires when those files change.

Test plan

  • Unit: go test ./pkg/compose/ -run 'TestGetWatchRules|TestInitialSync'
  • Repro with released docker compose watch on a root sync to /work: editing Dockerfile after start copies it into the container
  • Same steps with this binary: /work stays empty
  • Existing TestWatch* e2e cases do not cover this path; the full e2e suite was not run

Related issue
N/A

initialSync already skipped these after docker#14117, but getWatchRules never
did. A later edit was still copied into the container. Anchor the shared
ignore with **/ so it matches the watch loop's absolute paths, and apply
it only to copy actions so rebuild still fires.

Signed-off-by: orivital <orivital2924@gmail.com>
@Orivital
Orivital requested review from a team as code owners September 12, 2026 13:09
@Orivital
Orivital requested review from glours and ndeloof September 12, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant