Windows docker 构建网络问题

问题描述

我正在构建 Windows 映像,并且正在尝试安装 Chocolatey。但是,在 Chocolatey 的安装步骤中,我在尝试运行该命令时遇到下载超时。

这里是 Dockerfile,尝试使用 powershell 安装 Chocolatey。

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-20210112-windowsservercore-ltsc2019
SHELL ["powershell","-Command"]
RUN New-Item -ItemType directory -Path $Env:SOME_USER_HOME; \
    #Override the action to take in response to a non-terminanting error occurring,to STOP. 
    $ErrorActionPreference = 'Stop';
#Install chocolatey (https://chocolatey.org/docs/installation)
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
    Set-ExecutionPolicy Bypass -Scope Process -Force; \
    $env:chocolateyUseWindowsCompression = 'true'; \
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

错误

Exception calling "DownloadString" with "1" argument(s): "The operation has timed out" At line:1 char:179 + ... n = 'true'; iex((New-ObjectSystem.Net.WebClient).DownloadString('ht...

然后我尝试使用 Nuget CLI 安装 Chocolatey

RUN nuget install chocolatey

但我收到了类似的错误

Unable to load the service index for source https://api.nuget.org/v3/index.json.
The HTTP request to 'GET https://api.nuget.org/v3/index.json' has timed out after 100000ms.

我做了以下测试:

  1. 我可以在服务器中使用这两种方法在容器外安装 Chocolatey https://docs.chocolatey.org/en-us/choco/setup#install-using-nuget-package-manager
  2. 我可以在 Docker 容器中 ping 巧克力色.org 没有问题。
  3. 在另一台服务器中构建相同的图像没有问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...