Docker中的Chocolatey安装开始失败,由于.NET框架突然需要重新启动

2admgd59  于 2023-06-21  发布在  Docker
关注(0)|答案(3)|浏览(173)

Chocolatey安装上周开始失败。Dockerfile以

FROM python:3.8.2-windowsservercore-ltsc2016
SHELL ["powershell","-Command"]
RUN "Set-ExecutionPolicy Bypass -Scope Process -Force; [Net.ServicePointManager]::SecurityProtocol = 'tls12'; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"

log说:

Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)
Getting latest version of the Chocolatey package for download.
Not using proxy.
Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0 to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall
Installing Chocolatey on the local machine
The registry key for .Net 4.8 was not found or this is forced

Downloading 'https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe' to 'C:\Users\ContainerAdministrator\AppData\Local\Temp\ndp48-x86-x64-allos-enu.exe' - the installer is 100+ MBs, so this could take a while on a slow connection.

Installing 'C:\Users\ContainerAdministrator\AppData\Local\Temp\ndp48-x86-x64-allos-enu.exe' - this may take awhile with no output.

.NET Framework 4.8 was installed, but a reboot is required. 

Please reboot the system and try to install/upgrade Chocolatey again.

如何解决这一问题?

jpfvwuh4

jpfvwuh41#

在Dockerfile中指定较旧的chocolatey版本似乎有助于解决这个问题

ENV chocolateyVersion=1.4.0

这是上周下载的最新版本。

zu0ti5jz

zu0ti5jz2#

.NET Framework 4.8的要求已经讨论了一段时间,并且在发行说明和升级指南中都提到了。
https://docs.chocolatey.org/en-us/choco/release-notes#may-31-2023
升级到.NET Framework的目标版本4.8-请参阅#2738
https://docs.chocolatey.org/en-us/guides/upgrading-to-chocolatey-v2-v6#net-framework-4.8-required
我们建议您在安装或升级到Chocolatey CLI v2.0.0之前安装.NET Framework 4.8并重新启动。如果您要在Docker容器中安装Chocolatey,请使用已安装.NET 4.8的映像或使用official Chocolatey CLI Docker image
你可以在这里看到用于官方Chocolatey Docker镜像的基础镜像:
https://github.com/chocolatey/choco/blob/develop/docker/Dockerfile.windows#L1

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016
qij5mzcb

qij5mzcb3#

对于那些在无法升级到.NET 4.8的机器上通过PowerShell安装choco时遇到相同问题的人,请将此添加到您的PowerShell脚本以安装choco的早期版本并避免新的.NET 4.8要求:

$env:chocolateyVersion = '1.4.0'

然后还要确保您的脚本后面没有这一行,否则它将升级到choco2.0并安装.NET4.8

choco upgrade chocolatey -y -r

相关问题