Docker Community Forums

Share and learn in the Docker community.

Editing a source code file on host isn't reflected in running application


(Chribben) #1

Expected behavior

Changes to files in mounted volume on host should be picked up by the running container

Actual behavior

Changes are not picked up in container

Information

I’m running an application in a container with a mounted volume containing the source code of the app.
When changing a source code file directly in the container, this is reflected in the running application but doing a change on the same file on the host doesn’t have any effect on the app.

Host OS: Windows 10
Docker for Windows version: 1.10.6.958

Steps to reproduce the behavior

  1. Clone this repo and follow the instructions in the readme

(Michael Friis) #2

@chribben Thanks for the careful repro. This is also a problem with Docker Toolbox and is caused by imperfect mapping of Windows filesystem semantics into the Linux VM. Details here: https://github.com/aspnet/dotnet-watch/issues/55


(Chribben) #3

Thanks for the reply.
So Docker for Windows differ from Docker for Mac in this respect as the former requires polling the mounted volume?


(Rolf Neugebauer) #4

Hi @chribben
currently we SMB mount the host filesystem in the Linux VM so we are currently bound by whatever functionality that offers (and it doesn’t support change notifications, aka inotify, on the Linux side). On the Mac we are using a custom filesystem based on FUSE which allows us to reflect change events from the host into the Linux VM (where they pop up as inotify events). This isn’t perfect because there are some differences in the filesystem semantics between MacOS and Linux, but they are reasonably close.

We are looking into implementing something similar on Windows, but the filesystem semantics on Windows are significantly more different.


(Chribben) #5

@rneugeba Got it, thanks for the explanation!


(Doug Martin (https://github.com/dougmartin)) #6

@rneugeba You may want to look into whatever Vagrant does for bi-direction sync. Before installing Docker for Windows yesterday I was using a Vagrant built Ubuntu VM on Hyper-V to act as my Docker host using a shared folder. File synching works fine that way with changes on the Window’s side seen instantly on the Ubuntu VM side and vice-versa. This was using Vagrant’s synced_folder config option with the default sync type (not forcing it to SMB).


(Chribben) #7

@zoopdoop Do you mean that file change notifications are triggered in the Linux VM when files on the host (Windows machine) changes? This is not my experience but maybe something has changed since then?


(Rolf Neugebauer) #8

@zoopdoop Vagrant offers a number of different implementation for synched folders including SMB (which is what we are currently using in D4W). As @chribben points out, this will not support notifications of file changes.

Vagrant also supports rsync for synched folders which means copying files back and forth between host and VM as they change. This would trigger notifications in a Linux VM because files get updated locally, but only works in a small set of case and can lead to extremely unpredictable results. Consider changes to a number of files where a change to one file triggers a rebuild but the other files are still being copied…


(Michael Friis) #9

@chribben it’s not a satisfying solution and it doesn’t work in the general case, but Mono has a polling file watcher implementation. Here’s how to use it: https://github.com/chribben/docker-net-watch/pull/1/files


(Michael Friis) #10

@chribben looks like the MS guys have a solution ready: https://github.com/aspnet/dotnet-watch/issues/55#issuecomment-207141315


(Chribben) #11

Nice, I’ll try it out!