Skip to content

Ensure Dockerfile WORKDIR C:\ becomes / in LLB - #1621

Closed
TBBle wants to merge 1 commit into
moby:masterfrom
TBBle:dockerfile_workdir_paths
Closed

TBBle wants to merge 1 commit into
moby:masterfrom
TBBle:dockerfile_workdir_paths

Conversation

@TBBle

@TBBle TBBle commented Aug 1, 2020

Copy link
Copy Markdown
Collaborator

Putting this up for review as a first step towards implementing #616 (comment), to make sure we're happy with this approach. parseAdd will need similar fixes for its sources and destination arguments.

This change doesn't make WORKDIR actually work, as there are different issues when applying the LLB back to the filesystem, but those can be fixed separately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of using filepath and making decisions based on the native architecture, it would be better to move this to dockerfile2llb and use the platform of the dispatchstate

to make the decision about converting paths. Would like that windows dockerfile that doesn't use RUN would work on Linux as well, like it works today if unix paths are used.

This looks somewhat similar to #1560 that you also might want to take.

@TBBle TBBle Aug 2, 2020 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, is the idea that WORKDIR C:\test should work when running a Linux-based build against the Windows targetPlatform? That seems reasonable, but will require a little bit more learning on my part.

I assume WORKDIR C:\test should fail if the targetPlatform is Linux... Or rather, that's possibly a valid filename, but it's relative, and it's the filesystem layer's problem to reject it.

I like this more, because one of the outstanding concerns I had with my tests was the runtime platform check. I can split the current test into two, and confirm that we get rational behaviour for both Linux and Windows targetPlatform, irrespective of the execution platform.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, is the idea that WORKDIR C:\test should work when running a Linux-based build against the Windows targetPlatform?

Yes. This works today (outside Moby integration). But I think today you just always need to use unix paths that should work even if you build for windows. Normally, I would just always recommend using unix paths in Dockerfiles but because old builder already supports windows paths BuildKit should as well. But the same Dockerfile should be usable for building natively on Windows and cross-building on Linux.

I assume WORKDIR C:\test should fail if the targetPlatform is Linux...

Yes, we shouldn't try to do any normalization magic for linux targets. If target is windows we can check if it is a windows style path and normalize to unix path if needed.

@tonistiigi

Copy link
Copy Markdown
Member

ping @TBBle

@TBBle

TBBle commented Oct 19, 2020 •

Copy link
Copy Markdown
Collaborator Author

Sorry, I haven't had a chance to get back to this PR and rework it to apply the discussion outcome from the first review.

I planned to get back to this when the containerd PRs for Windows support landed, but they still haven't, and the whole thing fell off my radar.

Converted to draft, to make that clear. It really should have always been a draft, based on my own initial description. ^_^

@TBBle
TBBle marked this pull request as draft October 19, 2020 05:20
@TBBle
TBBle force-pushed the dockerfile_workdir_paths branch from d0bc1cc to 432f806 Compare December 12, 2020 18:49
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
@TBBle
TBBle force-pushed the dockerfile_workdir_paths branch from 432f806 to 0bbf9e5 Compare October 18, 2023 12:25
@tonistiigi

Copy link
Copy Markdown
Member

I guess this has been superseded with the WCOW patches.

@tonistiigi tonistiigi closed this Feb 10, 2024
@TBBle

TBBle commented Feb 10, 2024

Copy link
Copy Markdown
Collaborator Author

Probably true, yeah. I'll keep the branch around since all I'd done was add some tests, and it's possible it's still a coverage gap to close. But I expect the actual code is operating correctly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants