gpt4 book ai didi

docker - 如何在 docker 中使用 wsl(不是这样)

转载 作者:行者123 更新时间:2023-12-03 18:00:34 26 4
gpt4 key购买 nike

我想在 Windows 容器中使用 WSL。我希望我的 shell 是 dockerfile 中的 bash.exe(来自 Wsl 功能)(我做 不是 想要 msys2/relatives,但是 WSL 1 )
我试过

FROM mcr.microsoft.com/windows:1903
RUN dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
没有成功。
有人可以提示我金色 dockerfile 吗?

最佳答案

使用来自 microsoft.com 的 ISO 源文件,我设法找到丢失的“源文件”并启用 WSL 功能。
但它需要重新启动(并加载内核模块文件),而 docker 无法做到(AFAIK)。
我认为在 dockerfile 中使用 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

关于docker - 如何在 docker 中使用 wsl(不是这样),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65354976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com