vscode-remote-release
vscode-remote-release copied to clipboard
FileSystemWatcher not working on mounted directory in Docker Container
Using vscode.workspace.createFileSystemWatcher("**/my_file", false, false, false) in a vscode extension to watch file changes in the current workspace folder from Windows opened in a Docker container environment.
const fileWatcher = vscode.workspace.createFileSystemWatcher(
"**/my_file",
false,
false,
false
);
const fileWatcherDisposable = fileWatcher.onDidChange((e) =>
vscode.window.showInformationMessage(
`Watch event is executed`
);
);
context.subscriptions.push(fileWatcherDisposable);
If using a workspace that is not mounted to the container (a folder created within the container) or outside the container environment it works.
Is the mounted filesystem in Windows, WSL, macOS or Linux? Are the file changes made from within the container or from the host OS side?
Host machine is Windows 11 using Docker container with Dockerfile based on Ubuntu 24.04. I reopen in container an existing directory in Windows.
Changes are done inside the container using vscode dev container and running a command in the container terminal.
This issue could originate from a problem with file watching. Let me explain how file watching works in VSCode first and then provide some details how to get more logging data from how file watching behaves in your case.
Synopsis VSCode has different strategies for file watching depending on your workspace and setup:
- no folder opened: files in opened editors are watched via node.js
fs.watch - folder opened: folder is watched recursively for all changes via parcel, opened editors with files not within the folder are watched via node.js
fs.watch
If you are connected to a remote (SSH, WSL, Docker), the file watcher will run within the target file system. As such, even though you maybe on Windows where VSCode runs, if the remote is Linux, the file watcher will run in the Linux environment.
Platforms Depending on the platform you are on, file watching is differently implemented:
- macOS: using
fseventsservices - Windows: using
ReadDirectoryChangesWmethod - Linux: using
inotify
Specifically on Linux, watching a large folder recursively can result in VSCode consuming too many file handles. If that is the case, you will see a warning notification with instructions how to solve that.
Limitations File watching comes with a set of limitations:
- symbolic links are not followed automatically but you can explicitly add symbolic links to be watched via the
files.watcherIncludesetting - mapped network drives or third party file system drivers are not guaranteed to produce file events
- in general, the operating system may decide to drop file events at any time, there is no 100% guarantee
Settings
Please review your settings to see if maybe a folder is excluded by accident. Specifically, the files.watcherExclude setting is relevant.
Logging (local) !!! This is ONLY when you open a local workspace, for remote see below !!! We provide logging for file events when you enable verbose logging. Steps are:
- open VSCode on the local workspace that shows the issue
- select
View | Command Palette... - select
Developer - Set Log Level... - pick
Trace - select
View | Output - select
File Watcherfrom the dropdown on the right - attach the output when doing the operation that exhibits the issue
Logging (remote) !!! This is ONLY when you open a remote workspace (WSL, Docker, SSH), for local see above !!! We provide logging for file events when you enable verbose logging. Steps are:
- open VSCode on the remote workspace that shows the issue
- select
View | Command Palette... - select
Developer - Set Log Level... - pick
Trace - select
View | Output - select
Log (Remote Server)from the dropdown - attach the output when doing the operation that exhibits the issue

Log (Remote Server) doesn't exist.
On File Watcher no output related to Container. I can see some changes regarding Global Storage in the host system but nothing containing any container path.
You can try open an existing host machine folder in a devcontainer and modify the watched file in vscode text editor. You'll see no event triggered by file watcher. Based on your comment I observe this use case doesn't fall on file watcher limitation.
For me to understand the setup:
- you are on Windows using Docker for Windows
- you have a Ubuntu docker container you open with VS Code from Windows using docker remote VS Code extension
- you open a folder inside the docker container (or maybe not?)
- file changes are not working
Or is that folder mounted into the docker container from Windows? It is possible that the file watcher does not work in that case.
It is not clear from vscode api or Dev Container documentation that a FileWatcher doesn't not work if you re-open it in a container. Kind of something you would expect to work on a dev container. I understand now, based on your previous comment, that probably the windows host folder is network mapped to the dev container and in that case file watcher doesn't work because of underlying watch implementation.
Considering how dev container extension usually re-open a host folder into a container (at least is the common use case I see) seems important to notice.
I suggest from this conversation to update documentation. Thank you for your quick response.
@chrmarti can you please chime in, you might know from past experiences?
Otherwise this looks like a duplicate of https://github.com/microsoft/vscode/issues/212793 to me.
It is not clear from vscode api or Dev Container documentation that a
FileWatcherdoesn't not work if you re-open it in a container. Kind of something you would expect to work on a dev container. I understand now, based on your previous comment, that probably the windows host folder is network mapped to the dev container and in that case file watcher doesn't work because of underlying watch implementation.
Docker doesn't network map the mounted folder. I assume this is just a regular local folder on Windows?
On
File Watcherno output related to Container. I can see some changes regarding Global Storage in the host system but nothing containing any container path.
Please check the Server channel, the File Watcher only shows the local file watcher. Also make sure trace logging is still enabled.
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!