microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.48k stars 822 forks source link

Windows interop doesn't work for .exe files that live inside of a Docker container #11967

Open nrclark opened 2 months ago

nrclark commented 2 months ago

Windows Version

Microsoft Windows [Version 10.0.22631.3737]

WSL Version

2.3.17.0

Are you using WSL 1 or WSL 2?

Kernel Version

5.15.153.1-2

Distro Version

Ubuntu 22.04

Other Software

Docker (Ubuntu 22), version 24.0.7

Repro Steps

  1. Launch WSL (ubuntu-22.04).
  2. Run /mnt/c/Windows/System32/cmd.exe and it works fine.
  3. Run a custom some-program.exe that lives in Ubuntu's filesystem (maybe in /home/username) and it works fine.
  4. Start a Docker container with /run/WSL, /init, /mnt/wsl, /mnt/wslg, and /mnt/c bind-mounted into the container, and the WSL2_GUI_APPS_ENABLED WSL_INTEROP, and PULSE_SERVER enviroment variables passed through to the container.
  5. Run /mnt/c/Windows/System32/cmd.exe inside of the container and it works fine.
  6. Run a custom some-other-program.exe that lives only in the Docker container and it fails with ./some-other-program.exe: Invalid argument.
  7. Look up the path to some-other-program.exe in the host's /var/lib/docker/overlay2 and run it from there, and it works fine.

Expected Behavior

some-other-program.exe should be launchable from inside of Docker.

Actual Behavior

some-other-program.exe fails to launch from inside of Docker, possibly because of Docker container bind-mount path translation.

Diagnostic Logs

WslLogs-2024-08-28_23-33-06.zip

github-actions[bot] commented 2 months ago

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
Detected appx version: 2.3.17.0

OneBlue commented 2 months ago

@nrclark: Thank you for reporting this.

This is an interesting edge case. Since docker runs in a chroot, the path that the windows service receives is relative to that root, and therefore trying to create that process from Windows fails since that path doesn't exist in the distribution filesystem:

Microsoft.Windows.Subsystem.Lxss    LxssException   08-28-2024 14:33:23.346 "   "   "Code:  
File:   C:\__w\1\s\src\windows\common\SubProcess.cpp
FunctionName:   
HRESULT:    0x8007010B
Line number:    207
Message:    ""ApplicationName: \\wsl.localhost\Ubuntu-22.04\usr\local\stow\python-3.12.4-embed-amd64\share\python-3.12.4-embed-amd64\python.exe, CommandLine: python.exe, WorkingDirectory: \\wsl.localhost\Ubuntu-22.04\usr\local\stow\python-3.12.4-embed-amd64\share\python-3.12.4-embed-amd64""
Type:   0
wslVersion:     2.3.17.0"               22712   9900    2       00000000-0000-0000-0000-000000000000        

Adding support for this would essentially be a new feature, adding feature tag