pri*_*sar 6 nuget docker nuget-package-restore dockerfile docker-compose
在使用代理后面的 docker-compose 构建时出现金块恢复错误。我已经在 docker for windows 中设置了代理。Nuget 恢复适用于命令行dotnet restore和 Visual Studio 调试,但不适用于docker-compose.
:\Program Files\dotnet\sdk\2.1.104\NuGet.targets(104,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\WebApp.sln]
:\Program Files\dotnet\sdk\2.1.104\NuGet.targets(104,5): error : An error occurred while sending the request. [C:\src\WebApp.sln]
:\Program Files\dotnet\sdk\2.1.104\NuGet.targets(104,5): error : A connection with the server could not be established [C:\src\WebApp.sln]
ERROR: Service 'idenityapi' failed to build: The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore -nowarn:msb3202,nu1503' r
turned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)
解决了:
结果证明是网络问题。我在工作中使用公司防火墙,该防火墙利用 TLS 数据包检查来分解 SSL 流量。调试时的构建过程在我的本地机器上以“我”的身份运行,但是,发布构建(docker-compose)实际上会拉下一个 aspnetcore-build docker 镜像,将您的代码复制到 docker 容器,然后运行 dotnet restore 以获得新鲜docker 映像的 nuget 包。这些操作可以在项目的 Docker 文件中找到。容器内的这个“dotnet restore”在不同的安全上下文下运行,因此被挂断了。我们跟踪了网络流量,由于 docker 网络的工作方式,我很难获得这些流量。Fiddler 没有赶上交通。使用wireshark,我们能够从设备级别捕获它并看到下降。
解决方案:
为https://api.nuget.org/v3/index.json (首选)添加防火墙规则或从云中的 VSTS 构建映像或从不同的网络构建。
PS4如果你能以同样的方式解决这个问题,请回帖?花了3天的时间,我很好奇你的状态。
当我在dotnet restore添加公司证书文件时遇到这个问题时解决了这个问题。(在您的情况下可能相同也可能不同?)。在RUN dotnet restore我添加到容器的证书存储之前,即
ADD your-proxy-certificate-file.crt /usr/local/share/ca-certificates/your-proxy-certificate-file.crt
RUN update-ca-certificates
Run Code Online (Sandbox Code Playgroud)
从理论上讲,如果dotnet restore在本地机器上工作,没有理由你不应该能够配置您的容器中工作(不需要防火墙规则或改变网络!)。您基本上需要配置容器以使用与本地机器相同的设置在您的代理后面工作。
| 归档时间: |
|
| 查看次数: |
10651 次 |
| 最近记录: |