DockerFile with dotnet/sdk/5说没有cmd可执行文件在$PATH,而与/dotnet/framework/sdk:4.8,它工作正常
我们的dockerfile有。net framework 4.8 (mcr.microsoft.com/dotnet/framework/sdk:4.8),还安装了VS构建工具。
当前的要求是升级到使用。net 5.0 SDK而不是4.8。dotnet/SDK:5.0
DockerFile如下:
#FROM mcr.microsoft.com/dotnet/framework/sdk:4.8
FROM mcr.microsoft.com/dotnet/sdk:5.0
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
# Download the Visual Studio Build Tools bootstrapper.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:Tempvs_buildtools.exe
# Use the latest release channel.
ADD https://aka.ms/vs/16/release/channel C:TempVisualStudio.chman
# Set up environment to collect install errors.
COPY Install.cmd C:Temp
ADD https://aka.ms/vscollect.exe C:Tempcollect.exe
# Modify MSVC C++ compiler, CMake, and MSBuild.
RUN c:TempInstall.cmd C:Tempvs_buildtools.exe modify `
--quiet --wait --norestart --nocache `
--installPath "C:Program Files (x86)Microsoft Visual Studio2019BuildTools" `
--channelUri C:TempVisualStudio.chman `
--installChannelUri C:TempVisualStudio.chman `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools;includeRecommended `
--add Microsoft.VisualStudio.Workload.VCTools;includeRecommended `
--add Microsoft.Component.MSBuild `
--add Microsoft.VisualStudio.Component.VC.ATLMFC
# Start developer command prompt with any other commands specified.
WORKDIR /src
ENTRYPOINT ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Error is
container_linux.go:380: starting container process caused: exec: "cmd": executable file not found in $PATH
我的Docker桌面使用WSL2, Linux发行版安装的是Ubuntu 20.04 LTS
Docker在Linux containers
模式下出现此错误。执行命令切换:
"C:Program FilesDockerDockerdockercli" -switch
另一种方法是在托盘中找到Docker并选择Switch to Windows containers