Skip to content

Preserve POSIX absolute bind mount paths on Windows - #1518

Open
sgolev wants to merge 1 commit into
containers:mainfrom
sgolev:fix/posix-absolute-source-on-windows
Open

Preserve POSIX absolute bind mount paths on Windows#1518
sgolev wants to merge 1 commit into
containers:mainfrom
sgolev:fix/posix-absolute-source-on-windows

Conversation

@sgolev

@sgolev sgolev commented Jul 24, 2026

Copy link
Copy Markdown

On Windows, parse_short_mount() and assert_volume() unconditionally run os.path.abspath() on bind mount sources. For a POSIX absolute source like /etc/example, os.path.abspath() prepends the current Windows drive, producing C:\etc\example. As a result, when targeting a remote Linux host, podman-compose fails with:

statfs /mnt/c/etc/example: no such file or directory

The fix is to skip the rewrite when the source is POSIX absolute path on Windows. Relative, ~, .sock, and drive paths (C:\...) are unaffected.

This PR fixes #1352.

As a side note, assert_volume() doesn't work as intended when targeting a remote machine, because it ensures that directories exist on the local machine. I've tried to introduce minimal changes just to fix the Windows-to-remote-Linux workflow. When a POSIX absolute path is detected on Windows, both the rewrite and the local probe are skipped.

@sgolev
sgolev force-pushed the fix/posix-absolute-source-on-windows branch from 453db38 to c439ba1 Compare July 27, 2026 12:15
@p12tic

p12tic commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Shouldn't the proper fix be to switch to posix path module for any operations on a remote Linux machine?

@sgolev

sgolev commented Jul 29, 2026

Copy link
Copy Markdown
Author

If I understand you correctly, you're suggesting that we check whether we're running in remote mode and, in that case, switch to posixpath. But it helps only with absolute paths, so the behavior is essentially the same.

BTW, I found how Docker Compose handles paths: https://github.com/compose-spec/compose-go/blob/ace34ebd2aae2913524151b2b02e67790c88983c/paths/unix.go#L38. So they check whether the path is absolute in either POSIX or Windows notation leaving it unchanged if it is.

The corresponding Python code would be:

is_abs = os.path.isabs(mount_src) or secondarypathisabs(mount_src)
if not is_abs and (os.name != 'nt' or ".sock" not in mount_src):

@p12tic

p12tic commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@sgolev

The corresponding Python code would be: <...>

Makes sense. I think we could do exactly as this, since this makes maximum compatibility with docker compose. Probably makes sense to introduce it as a function.

@sgolev
sgolev force-pushed the fix/posix-absolute-source-on-windows branch 2 times, most recently from 885ebf8 to 0f4bfe3 Compare August 7, 2026 13:18
On Windows, parse_short_mount() and assert_volume() unconditionally
run os.path.abspath() on bind mount sources. For a POSIX absolute
source like /etc/example, abspath() prepends the current drive,
producing C:\etc\example. As a result, when targeting a remote Linux
host, podman-compose fails with:

    statfs /mnt/c/etc/example: no such file or directory

Skip the rewrite when the source is POSIX absolute on Windows.
Relative, ~, .sock, and drive paths are unaffected.

Fixes containers#1352

Signed-off-by: sgolev <53184912+sgolev@users.noreply.github.com>
@p12tic
p12tic force-pushed the fix/posix-absolute-source-on-windows branch from 0f4bfe3 to 58b6a93 Compare August 10, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to mount paths inside WSL podman machine when running on Windows

2 participants