如何在 docker 中使用 wsl(不是绕过的方法)

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

我想在 windows 容器中使用 WSL。我希望我的 shell 成为 bash.exe(来自 Wsl 功能)在 dockerfile 中(我 NOT 想要 msys2/relatives,但是 WSL 1)

我试过了

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

没有成功。 有人可以向我提示 golden dockerfile 吗?

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

我按照这些文档安装了 Ubuntu 和 Docker。
我正在使用 Windows 10 Home x64,它工作正常。

谢谢

使用来自 microsoft.com 的 ISO 源文件,我设法找到了丢失的“源文件”并启用了 WSL 功能。

但它需要重新启动(并加载内核模块文件) docker 不能(AFAIK)。

我认为在 docker 文件中使用 WSL 是不可能的。

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