由于 dotnetfx
,我需要在构建过程中重新启动 Docker 容器。 Dockerfile
:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Install Chocolatey
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Universal Windows Platform build tools workload for Visual Studio 2019 Build Tools (https://chocolatey.org/packages/visualstudio2019-workload-universalbuildtools#dependencies)
RUN choco install visualstudio2019-workload-universalbuildtools --package-parameters "--includeOptional" --confirm
但是我面临着这个错误:
Packages requiring reboot:
- dotnetfx (exit code 3010) # <--- it means a reboot is needed!
我尝试在同一个
RUN
命令中运行这两个命令,并在它们之间添加Restart-Computer
(用\
分隔),或者在每个安装命令后执行一个RUN
命令,但是当我这样做时,Docker输出好像丢失了。在构建过程中,我可以重新启动当前容器而不让Docker丢失并保持安装进程吗?
更新1 尝试在运行最后一个命令之前安装
dotnetfx
,但是我收到相同的错误。# Microsoft .NET Framework (https://chocolatey.org/packages/dotnetfx)
RUN choco install dotnetfx --confirm
错误:
Packages requiring reboot:
- dotnetfx (exit code 3010)
更新 2(解决方法)
我已经成功地使用一个已经安装了.NET的基础镜像解决了这个问题:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8