-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
WCOW/dockerfile fontend: consistency in handling slashes slashes in C:\\ #4696
Comments
I had started looking into this in #1621, but didn't get much further than some tests and a draft resolution approach that was determined to be the wrong approach. The branch is still around if anyone wants to look at it, as I suspected the issue was still around. See also #616 (comment) That said, this one in particular might be not a problem with COPY per-se, but with the end-of-line continuation character. Does FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
COPY hello.txt C:\\
CMD ["cmd", "/C", "type C:\\hello.txt"] work? |
I remember briefly looking at this a while ago and ending up somewhere in the While almost all Dockerfile stanzas will be fine with using # Actuall SHELL stanza parameters may differ
SHELL ["powershell.exe", "-Command"] and use PowerShell as a shell instead of |
@TBBle -- thanks for taking a look. You are right, the issue is with FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
COPY hello.txt C:\\
CMD ["cmd", "/C", "type C:\\hello.txt"] I get this:
|
That error suggests we're failing at https://github.com/moby/buildkit/blob/master/util/system/path.go#L190-L193. I suspect, based on rough recollection of #1621 investigations, that the parse correctly produced I don't think we saw this when building Windows containers on Linux though, but I don't remember why. The discussion in #1621 for this sort of issue was that dockerfile2llb should take care of this sort of thing, and LLB should only see unix-style paths. During container build steps that aren't (Edit: Just noticed that this failure is probably happening during dockerfile2llb processing ( Also, I'll note that my repro in #1621 was with |
@TBBle -- yes, looks close. Found this on my debugging,
Further up:
Looks like |
We have an edge case situation coming from a path like C:\\ The drive letter is stipped out and \\ remains and therefore appended with / to get `/\\`. normalizePath is suppposed to also standardize this path to unix format and it wasn't doing so, the path was returning as is. With this minor fix, `/` will be returned instead. fixes moby#4696 Signed-off-by: Anthony Nandaa <[email protected]>
We have an edge case situation coming from a path like C:\\ The drive letter is stipped out and \\ remains and therefore appended with / to get `/\\`. normalizePath is suppposed to also standardize this path to unix format and it wasn't doing so, the path was returning as is. With this minor fix, `/` will be returned instead. The commit also improves the error message to be specific if the error is from dest or src path, for a COPY. fixes moby#4696 Signed-off-by: Anthony Nandaa <[email protected]>
In the case for Windows, this line at frontend/dockerfile/dockerfile2llb/convert.go#L1142 ```go dest += string(filepath.Separator) ``` was adding the `\\` to a path that is already normalized to unix-format, hence ending up with dest paths like `/\\` for `C:\\` and `/test\\` for `C:\\test\\`. the src paths are well normalized too at ~L1290. fixes moby#4696 Signed-off-by: Anthony Nandaa <[email protected]>
In the case for Windows, this line at frontend/dockerfile/dockerfile2llb/convert.go#L1142 ```go dest += string(filepath.Separator) ``` was adding the `\\` to a path that is already normalized to unix-format, hence ending up with dest paths like `/\\` for `C:\\` and `/test\\` for `C:\\test\\`. the src paths are well normalized too at ~L1290. fixes moby#4696 Signed-off-by: Anthony Nandaa <[email protected]>
In the case for Windows, this line at frontend/dockerfile/dockerfile2llb/convert.go#L1142 ```go dest += string(filepath.Separator) ``` was adding the `\\` to a path that is already normalized to unix-format, hence ending up with dest paths like `/\\` for `C:\\` and `/test\\` for `C:\\test\\`. the src paths are well normalized too at ~L1290. This change removes the block of code and instead does the "/" appending using the keepSlash logic that is in system.NormalizePath called in pathRelativeToWorkingDir() function before. fixes moby#4696 Signed-off-by: Anthony Nandaa <[email protected]>
Issue raised by the note in this doc has been closed refer to moby#4696 Signed-off-by: Billy Owire <[email protected]>
Issue raised by the note in this doc has been closed refer to moby#4696 Signed-off-by: Billy Owire <[email protected]>
docs: remove note since issue #4696 was fixed
Issue raised by the note in this doc has been closed refer to moby#4696 Signed-off-by: Billy Owire <[email protected]>
I have noticed we have some inconsistencies on how the dockerfile frontend handles the paths for Windows. I'm opening this issue quickly to track this but I'll provide better details with more tests.
So far, I've noticed this with
COPY
, but I need to do more tests.Repro Steps
Dockerfile:
Build command:
Expected error:
Current Fix/Work-around
General rule of thumb: Use
/
instead of\
for paths, for a consistent experience.For the above error, changing
C:\
inCOPY
stanza toC:/
fixes it./cc. @gabriel-samfira
The text was updated successfully, but these errors were encountered: