5

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 ?

131
  • 3,071
  • 31
  • 32
  • 1
    I don't think it is that easy https://github.com/Microsoft/WSL/issues/3555 – x4k3p Dec 26 '20 at 16:59
  • 1
    did you get a chance to look this https://stackoverflow.com/questions/58187147/unable-to-use-mcr-microsoft-com-windows-servercoreltsc-when-building-from-azure – Nadeem Taj Dec 26 '20 at 17:02
  • If it's only about getting a bash shell - have you tried installing cygwin instead of WSL . Cygwin will provide you with similar capability of running a shell with linux/unix commands. – vbn Dec 28 '20 at 08:16
  • 1
    hello check out these two links, https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly after the above steps your issue still not resolve so kindly write here, I'll do some debug on this issue – saqib kafeel Dec 28 '20 at 09:54
  • 1
    @vbn There is a big difference: in WSL the excution env is GNU/Linux , in Cygwin, it's windows. – Soleil Dec 28 '20 at 13:39

2 Answers2

0

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
131
  • 3,071
  • 31
  • 32
-2

https://learn.microsoft.com/en-us/windows/wsl/install-win10

I followed these docs for installing Ubuntu and Docker.
I'm using Windows 10 Home x64 and it's working fine.

Thanks