-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git clone does not work in Windows Docker container in mounted host volume folder #1007
Comments
Thank you for this very thorough report. I won't be near my laptop until next year, so I can only hope that other developers can reproduce the issue in the meantime. One request from my side before that, though: we fixed a UNC path issue recently and I wonder whether it magically fixes the bug you reported, too. Would you mind testing again with https://github.com/git-for-windows/git/releases/tag/v2.11.1.windows-prerelease.1 ? |
Thanks. I've tried the v2.11.1.windows-prerelease.1, but there is the same error message. No hurry, Docker on Windows is all new. Interesting enough I started to investigate a problem in Node.js which is very similar nodejs/node#8897, digging down to libuv and the build script there tries to clone a git repo and so I found this problem ;-) |
Okay. Would you mind pinging me after Jan 2nd so this issue does not fall off my radar? |
I got the same issue. It happens when I try to clone into a mounted volume or a subdirectory of it. |
I have the same issue. In my case, this is Jenkins that is trying to check-out code before a build. My JENKINS_HOME folder is mounted as a volume. |
There is a workaround for programs that want to retrieve the real path of a file or directory. Use a mapped drive letter of that volume and the program stops at the drive letter without stumbling at the volume reparse point. See an example in my slides: |
The culprit seems to be that |
The |
It means that (we use that in However, please note that in this case, it is a red herring. There is no such path... the output of
However, the link target as per |
And here is a related docker/docker ticket: moby/moby#31089 |
Just found this comment https://go-review.googlesource.com/c/41834/ in a commit to fix it for Golang.
|
Interesting. So the concrete take-home message is: we should override We already have code in So that looks like a viable route forward. It would be really awesome if somebody interested in this issue could take a stab at it (hint, hint) ;-) |
I did a short test with See https://github.com/StefanScherer/dockerfiles-windows/blob/master/realpath/README.md for some details. Golang's fix is just for their stat() function, they don't want to retrieve the real path of a file/directory. |
Same behavior with git init: But it doesn't work in a subdir either: mkdir test |
@romerod Thank you! However, re-confirmation is no longer necessary at this stage. Help with fixing it would be much appreciated, though. |
FWIW I can corroborate @StefanScherer 's findings, at least partially: If I run this #define _WIN32_WINNT 0x0600
#include <stdio.h>
#include <windows.h>
int main(int argc, char **argv)
{
int ret = 0;
HANDLE h = CreateFileW(L".", 0, FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS,
NULL);
wchar_t buf[1024];
if (h == INVALID_HANDLE_VALUE) {
fprintf(stderr, "Not a valid handle\n");
return 1;
}
if (!GetFinalPathNameByHandleW(h, buf, 1024, 0)) {
fprintf(stderr, "Error %d\n", (int)GetLastError());
ret = 1;
} else
printf("result: '%S'\n", buf);
CloseHandle(h);
return 0;
} in a directory mapped into Docker, funnily enough I get an This is on Windows 10 Enterprise, Creators' Update. |
Well I took a look how to help and installed the Git for Windows SDK in a Win2016 VM. Also tried to put all this into a Windows container with a
But most of the tools just won't start, maybe the containerized setup is not fully correct, missing variables or registry keys - I haven't figured out everything yet.
So this is my setup right now: The installer already comiled git and the test binaries on the Win2016 Docker host, now I also have the binaries in a Windows Container image. Which code would be relevant to investigate, how to recompile only the minimal parts? |
Wait, wait, wait. I just rebuilt my test Docker image described in https://github.com/StefanScherer/dockerfiles-windows/tree/master/git-for-windows-issue and ran the tests and all tests are working correctly.
My environment: Windows Server 2016 with all updates installed until revision 1198, Git-for-windows 2.13.0 in a Windows container, Docker 17.05.0-ce.
Repeated the test with git 2.11.0 and still have the error:
So it seems that there already is a fix in git-for-windows 2.13.0 👍 |
|
Result "git init" with 2.13: C:\buildAgent\work\test>"C:\Program Files\Git\bin\git.exe" init |
Yes, we know that this fails, and we know in the meantime why it fails, too: the mapped directory is represented as a symbolic link and the target is not accessible as-is, so we cannot resolve it. The question is not whether it breaks at this point. We know it breaks. The question is how to go about fixing it. We could reimplement the entire We could try to adjust the code in We could also patch Or we could hide that reparse reading inside I still hope that somebody comes up with a brilliant idea how to detect that we're running in Docker, or even enumerate the mapped directories and mark them as non-symlinks, or some such. That would provide a much better user experience. Anybody? |
Thanks @dscho sharing all these ideas. I also hesitate to dig deeper at the moment as I also see no simple solution. I have talked with some at Microsoft about this pain point as it seems a lot of other languages / frameworks / tools have the same problem getting the real path. What I have heard is that is won't be fixed in Win2016. But now you can think, will Microsoft fix this in another server release in the future, fixing some API's, making them easier to use etc.? I don't know. But at some point they surprise us with new features and then a massive code change in git-for-windows may be not needed. So for now I see others use the drive mapping workaround which works in Java / Jenkins / Bonobo Git Server etc. - maybe that would help us until we have more information if this will be fixed in the OS / API level or must be changed in all 3rd party tools. |
Similar way none msys2/mingw/cygwin/git-bash tool can handle docker-mounted path.
Is it exactly the same problem or just related? |
I'm a bit confused @StefanScherer didn't you comment on the 12. of May that the following works: Eitherway, I tried the workaround with teamcity, I've set the workdir to be G:\ and mapped the volume to C:\buildAgent\work. The clone part works, thanks at the genius who found that solution. But unluckily "git reset" fails with: Anyone found a solution to that? /cc @JetBrains |
Gaaaaah! Thank you so much. In yet another 30 minutes or so, a corrected snapshot should be available... |
Goal is almost there !!
to
Sorry this was my miss ... |
Oy vey. Thanks for your patience and diligence, @ZCube! |
It's better than just >=0. https://github.com/ZCube/drone-windows-container-test/tree/with-git-for-windows-snapshot proc "pipeline_clone_0" started
+ git init
Initialized empty Git repository in c:/test/src/github.com/drone/envsubst/.git/
+ git remote add origin https://github.com/drone/envsubst.git
+ git fetch --no-tags --depth=50 origin +refs/heads/master:
From https://github.com/drone/envsubst
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
+ git reset --hard -q d0876d3176965f9552a611cbd56e24a9264355e6
+ git submodule update --init --recursive
exit status 66
proc "pipeline_clone_0" exited with status 1
pipeline_clone_0 : exit code 1 |
@ZCube Here you are: https://wingit.blob.core.windows.net/files/index.html |
It works well.
|
@dscho The same error (Invalid path '/ContainerMappedDirectories': No such file or directory) is also occurring with submodule updates. Will your fix also work for submodules? |
@sp-jonathan-davis How about use this Dockerfile? FROM microsoft/windowsservercore
RUN powershell.exe [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
Invoke-WebRequest "https://wingit.blob.core.windows.net/files/MinGit-prerelease-2.17.0.windows.1.36.gdf4ca5fb72-BusyBox-64-bit.zip" \
-OutFile MinGit-prerelease-2.17.0.windows.1.36.gdf4ca5fb72-BusyBox-64-bit.zip -UseBasicParsing ; \
Expand-Archive 'MinGit-prerelease-2.17.0.windows.1.36.gdf4ca5fb72-BusyBox-64-bit.zip' -DestinationPath "c:/Git" -Force ; \
Remove-Item .\MinGit-prerelease-2.17.0.windows.1.36.gdf4ca5fb72-BusyBox-64-bit.zip && \
setx /m PATH "%PATH%;C:\Git\cmd"
# volume test
VOLUME "C:\\code"
RUN powershell.exe set-itemproperty -path \
'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices' \
-Name 'V:' -Value '\??\C:\code' -Type String
WORKDIR "V:\\" Test Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
V:\>dir c:\
Volume in drive C has no label.
Volume Serial Number is 047C-45B9
Directory of c:\
04/26/2018 11:30 PM <SYMLINKD> code [\\?\ContainerMappedDirectories\B5466CAA-AE78-4A16-9C36-1A4B186A3052]
04/26/2018 11:30 PM <DIR> Git
11/23/2016 07:45 AM 1,894 License.txt
03/05/2018 04:42 AM <DIR> PerfLogs
03/05/2018 04:53 AM <DIR> Program Files
07/16/2016 10:18 PM <DIR> Program Files (x86)
03/05/2018 04:54 AM <DIR> Users
03/05/2018 04:52 AM <DIR> Windows
1 File(s) 1,894 bytes
7 Dir(s) 128,568,999,936 bytes free
V:\>dir
Volume in drive V is 1TB
Volume Serial Number is 8A15-5E5F
Directory of V:\
04/26/2018 11:30 PM <DIR> .
04/26/2018 11:30 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 88,219,541,504 bytes free
V:\>git clone https://github.com/githubtraining/example-dependency --recursive
Cloning into 'example-dependency'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
Submodule 'js' (https://github.com/githubtraining/example-submodule.git) registered for path 'js'
Cloning into 'V:/example-dependency/js'...
remote: Counting objects: 18, done.
remote: Total 18 (delta 0), reused 0 (delta 0), pack-reused 18
Submodule path 'js': checked out 'c3c588713233609f5bbbb2d9e7f3fb4a660f3f72'
V:\>cd /d c:\code
c:\code>dir
Volume in drive C has no label.
Volume Serial Number is 047C-45B9
Directory of c:\code
04/26/2018 11:31 PM <DIR> .
04/26/2018 11:31 PM <DIR> ..
04/26/2018 11:31 PM <DIR> example-dependency
0 File(s) 0 bytes
3 Dir(s) 88,219,447,296 bytes free
c:\code>git clone https://github.com/githubtraining/example-dependency --recursive test2
Cloning into 'test2'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
Submodule 'js' (https://github.com/githubtraining/example-submodule.git) registered for path 'js'
Cloning into 'c:/code/test2/js'...
remote: Counting objects: 18, done.
remote: Total 18 (delta 0), reused 0 (delta 0), pack-reused 18
Submodule path 'js': checked out 'c3c588713233609f5bbbb2d9e7f3fb4a660f3f72'
c:\code>exit |
@ZCube Using "MinGit-prerelease-2.17.0.windows.1.36.gdf4ca5fb72-BusyBox-64-bit.zip" I get the following output when trying to clone a project in Jenkins running on a Windows Server 2016 container.
I wasn't originally able to clone the project so this version is a massive improvement for me. :) |
@sp-jonathan-davis Could you check the version of git? or test with above dockerfile?
|
Using the supplied Dockerfile the submodules are not checked out. When running the Edit: I have tested with a freshly created repo with submodules and everything worked. My problem with this specific repo seems to be unrelated to this issue. Thanks for the help! |
So can we close this now, thanks to #1645? |
I am still encountering the same issue ( I am running a container based upon The commit seems to have fixed the issue regarding |
I think we should try this in the new 1809 images (mcr.microsoft.com/windows/servercore:ltsc2019 mcr.microsoft.com/windows/nanoserver:1809) and and Windows Server 2019 / Windows 10 1809. |
Actually I solved this exact issue moving from ltsc2016 based images to ltsc2019 ones. |
I hope this is resolved in the meantime. If not, the ticket is too stale to leave it open. |
Setup
defaults?
to the issue you're seeing?
Running Git for Windows in a Windows Container directly on a volume mount point.
Details
PowerShell
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Running inside a Windows container works fine:
Running in a Windows container with a volume mounted from the Windows Docker host does not work:
The Container directory
C:\work
is mounted from the Docker host. This can be shown with thedir
command like this:It seems to me that Git is converting the UNC path into something and tries to switch to the "directory"
ContainerMappedDirectories
.Running in a Windows container with a volume mounted from the Windows Docker host works if I use a sub directory below that mount point:
Git clone should work directly in the mounted volume directory. I encountered that problem trying to build and test libuv in a container on a mapped volume. They have a command to clone into a sub directory
git clone https://chromium.googlesource.com/external/gyp build/gyp
but that also doesn't work if current dir in the container is the volume mount point.URL to that repository to help us with testing?
No specific repo. But I have put this test scenario at https://github.com/StefanScherer/dockerfiles-windows/tree/master/git-for-windows-issue with the build and test scripts.
To build the Windows Docker image this
Dockerfile
is neededand then build the Docker image with
The text was updated successfully, but these errors were encountered: