我想在Windows Docker Container中使用Bash for Windows(适用于Linux的Windows子系统)。
使用案例:我有一个Windows应用程序(我想要停靠),它还需要运行某些Linux命令。
我尝试创建启用了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.
问题:这在技术上是否可行?如果是,我将如何编写Dockerfile?