Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use wsl in docker (not the way around)

I want to use WSL in a a windows container. I want my shell to be bash.exe (from the Wsl feature) IN the dockerfile (i do NOT want msys2/relatives, but WSL 1)

I tried

FROM mcr.microsoft.com/windows:1903
RUN dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 

With no success. Can someone hint me to the golden dockerfile ?

like image 374
131 Avatar asked Oct 16 '25 17:10

131


1 Answers

Using an ISO source file from microsoft.com, i have managed to find the missing "source files" and enable WSL feature.

But it requires a reboot (and kernel module files to be loaded) witch docker cannot do (AFAIK).

I think using WSL in dockerfile is impossible.

curl -L -o windows.iso https://software-download.microsoft.com/download/pr/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso
7z x "-i!sources/install.wim" windows.iso
7z x "-i!1/Windows/WinSxS" sources/install.wim
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /Source:"%cd%/1/Windows/WinSxS"  /all /norestart
del windows.iso
rd /S /Q "sources"
rd /S /Q "1"
dir
like image 54
131 Avatar answered Oct 18 '25 06:10

131



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!