Windows容器中的WSL

我想在Windows Docker容器中使用Bash for Windows(Linux子系统)。

使用案例:我有一个Windows应用程序(我想dockerize),这也需要运行某些Linux命令。

我试图创build一个启用WSL的图像:

FROM microsoft/windowsservercore SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # Enable Developer Mode RUN New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -ItemType Directory -Force RUN New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1 # Enable WSL RUN Enable-WindowsOptionalFeature -FeatureName Microsoft-Windows-Subsystem-Linux -Online -All -NoRestart 

但是, Enable-WindowsOptionalFeature : Feature name Microsoft-Windows-Subsystem-Linux is unknown.失败Enable-WindowsOptionalFeature : Feature name Microsoft-Windows-Subsystem-Linux is unknown.

:这在技术上甚至可能吗? 如果是,我将如何编写Dockerfile?