Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Docker

Docker: Fix compose watch Ignoring a Renamed Source File

- 02.12.26 - ErcanOPAK

🐳 Docker: Fix compose watch Ignoring a Renamed Source File

Compose’s watch feature (the built-in replacement for a lot of bind-mount-plus-nodemon dev setups) tracks changes by watching the specific paths listed under each service’s develop.watch entries, matching against the path and any ignore globs you’ve configured — and that file-system watcher reacts to write and modify events on existing paths, not to a rename. Renaming a tracked source file is, from the underlying filesystem notification API’s point of view, a delete of the old path followed by a create of a new one, and if the new filename happens to fall outside the configured path pattern (a slightly different extension, a path depth the glob didn’t anticipate) compose watch silently stops tracking it from that point on, with no error and no log line calling out that a watched path just disappeared.

🔎 The Problem

# compose.yaml
services:
  web:
    develop:
      watch:
        - action: sync
          path: ./src
          target: /app/src
          ignore:
            - "**/*.test.js"

# Developer renames src/handlers/order.js -> src/handlers/orderHandler.js
# while docker compose watch is running:

$ docker compose watch
[+] watch sync initial scan complete
  -> watching src/handlers/order.js       # tracked
  -> (no corresponding line ever appears for orderHandler.js)

# Edits to orderHandler.js afterward never sync into the container -
# the running app keeps serving the stale old file's compiled output

✅ Fix: Restart the Watcher After Any Rename, and Watch Directories Not Files

  • Point develop.watch[].path at the containing directory (./src) rather than individual filenames wherever possible — a directory-level watch picks up a new filename on its next scan the moment a file appears under it, instead of needing to already know that exact name in advance.
  • Restart docker compose watch after any rename or move of a tracked file during active development — the watcher’s internal path list is built once at startup from the filesystem state at that moment, and it has no live reconciliation step that notices a tracked path vanished.
  • Add a quick sanity check to the dev workflow (a wrapper script, or just a habit) that runs docker compose watch with --no-up and -v briefly after a bulk rename, confirming every expected path still shows up in the initial scan log before trusting the session to sync correctly.

🚨 Why This Is Dangerous

  • The container keeps running and keeps responding, so a renamed file that silently stopped syncing looks identical to a working dev loop right up until someone spends real time debugging why their latest code change “isn’t taking effect,” when the container is actually still running the file from before the rename.

compose watch tracks paths, not intent — and a rename that your editor shows as one smooth operation is, to a filesystem watcher, an old path disappearing and a new one it was never told to look for.

— DevOps Engineer

Related posts:

Docker: Master Container Logging for Debugging

Docker: Master Container Logging for Debugging

Docker: Use Swarm for Container Orchestration

Docker: Use Swarm for Container Orchestration

Docker: Fix a Healthcheck Interval Too Slow to Catch a Crash Loop

Docker: Fix a Healthcheck Interval Too Slow to Catch a Crash Loop

Views: 0
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

C#: Fix a Generic Math Operator Not Resolving for a Custom Type
The AI Prompt That Sniffs Out an Auth Timing Side-Channel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 869 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com