0

带有 dotnet/sdk/5 的 DockerFile 表示 $PATH 中没有 cmd 可执行文件,而使用 /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:\Temp\vs_buildtools.exe

# Use the latest release channel.
ADD https://aka.ms/vs/16/release/channel C:\Temp\VisualStudio.chman
# Set up environment to collect install errors.
COPY Install.cmd C:\Temp\
ADD https://aka.ms/vscollect.exe C:\Temp\collect.exe

# Modify MSVC C++ compiler, CMake, and MSBuild.
RUN c:\Temp\Install.cmd C:\Temp\vs_buildtools.exe modify `
    --quiet --wait --norestart --nocache `
    --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" `
    --channelUri C:\Temp\VisualStudio.chman `
    --installChannelUri C:\Temp\VisualStudio.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"]

我得到的错误是

container_linux.go:380: starting container process caused: exec: "cmd": executable file not found in $PATH

我的 Docker 桌面使用 WSL2,安装的 Linux 发行版是 Ubuntu 20.04 LTS

4

0 回答 0