Run `wslc` from within a WSL distro
Is your feature request related to a problem? Please describe.
I want to run my wslc commands from within a WSL distro.
Describe the solution you'd like
Support the wslc binary from within any WSL distro.
Describe alternatives you've considered
Use wslc.exe but then file mounting is hard.
Additional context N/A
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
/feature
Diagnostic information
Found '/feature', adding tag 'feature'
/feature
Agree this would be valuable — the main friction right now is that wslc.exe is a Windows binary, so from inside a WSL distro you can call it via /mnt/c/Program Files/WSL/wslc.exe but file mounting becomes painful because the paths need to be Windows-side paths (e.g. C:/work:/app), not Linux paths from the distro.
A wslc binary inside the distro that understands Linux filesystem paths would make two workflows much cleaner:
- Shell scripts that mix wslc commands with other Linux tooling (no path translation needed)
- CI/CD inside a WSL distro that wants to use wslc instead of Docker (currently you have to call
wslc.exefrom PowerShell on the Windows side)
As a temporary bridge until a native distro binary ships, a small shell wrapper that translates Linux paths to their /mnt/c/... Windows equivalents before calling wslc.exe would cover the common cases. (For the reverse — Windows-side path conventions — the install guide at https://wslcontainers.com/guides/install/ covers the prerequisites.)
I’d really like to see this implemented.
In wslc-wip, I currently work around this by copying the build context to a temporary directory under /mnt/c before running wslc build.
This significantly improves build performance compared with using the build context directly from the WSL filesystem.
However, ideally, wslc-wip shouldn’t need this kind of workaround at all.
If wslc could run natively from within a WSL distro and handle WSL filesystem paths efficiently, this extra copy step could be removed.
The worst part about this is that there is a documentation page on the Microsoft learn website that talks about running wslc inside of a distro https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers#build-and-run-your-own-container-image so this induced me in error thinking that there was the wslc executable available inside of my distro