Git stash too strong for Hyper-v file sharing?

With the latest version of Docker for Windows and a mobylinux.
I have a php git repository that 2 of my containers use. I modify a random file on the host :

Then I do these git command one after the others :

git stash # ok
git stash pop # ok
git stash # ok
git stash pop # ok
git stash : => Takes 1 minute, then :
error: unable to create file Permission denied
fatal: Could not reset index file to revision 'HEAD'.

I also noticed that from inside the container :

root@317635dc4f03:watch -n 1 head
Every 1.0s: head
head: cannot open '' for reading: Stale file handle

Then, still from the container

head: cannot open '' for reading: No such file or directory

On the Window host the file is visible but I can’t open it neither delete it (permission denied)

To fix it, I need to stop docker, stop the Hyper-V MobyLinuxVM,and wait to be able to restore the file with a git reset --hard
Is there any way to avoid this kind of file sharing problem ?


Docker 17.06.0-ce | Windows 10 pro : 15063.540 | Hyper-V : 10.0.15063.0 | Moby, trusty,

My proposal would be. … **Just share the stuff that is needed, inside the containers, and let the .git directory reside somewhere else".

-------- reasoning: -------------

IMO that assumption to “modify a random file” where “a” == 1, is wrong. You are probably changing a dozen or more files. The git CLI works with the .git``directory. So your stash commands probably change a dozen files in the .git directory, that are probably all synced to the container, if they are shared. …

The “Docker 4 Windows” file sharing functionality is based on the CIFS protocol which has a lot of moving parts. See the “Figure B.17 CIFS Architecture” at the link.

The git cli commands think, they are using direct file access. They don’t care, if there is a “network” in between. So it seems somewhere on the way of syncing, something goes wrong. …


Hi, thanks Mario, it sounds like it is a good lead to avoid sharing the .git folder.

Is there any docker config that would help ? What about the .dockerignore file ?

Otherwise there is always

git --git-dir=../repo --work-tree=.
git init --separate-git-dir /path/to/repo.git


IMO you could use the post-commit hook, to rsync the changed files. see:

git show --pretty="" --name-only should give you the names of the files form the last commit. … google will be your friend :slight_smile: