docker - 无法加载源 https://api.nuget.org/v3/index.json 的服务索引。[C:\app\aspnetapp.csproj]
问题描述
https://github.com/dotnet/dotnet-docker-samples/tree/master/aspnetapp
码头工人命令docker build -t aspnetapp
。
我收到 docker build 命令的错误
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): 错误:无法加载源https://api.nuget.org/v3/index.json的服务索引。[C:\app\aspnetapp.csproj]
[1]PS C:\Users\pssharma\dotnet-docker-samples\aspnetapp> docker build -t aspnetapp .
Sending build context to Docker daemon 2.444MB
Step 1/10 : FROM microsoft/aspnetcore-build:2.0 AS build-env
---> eb21d939e0d8
Step 2/10 : WORKDIR /app
---> Using cache
---> d4ec30216ed7
Step 3/10 : COPY *.csproj ./
---> Using cache
---> 2ff39b5e6cb4
Step 4/10 : RUN dotnet restore
---> Running in 776764a35311
Restoring packages for C:\app\aspnetapp.csproj...
Restoring packages for C:\app\aspnetapp.csproj...
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\asp
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : An error occurred while sending the request. [C:\app\aspnetapp.csproj]
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : The operation timed out [C:\app\aspnetapp.csproj]
以下命令返回一个非零代码:1
powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore
解决方案
当主机存在多个网络适配器并且所述适配器的优先级配置错误时,这似乎会发生。运行以下命令以显示网络适配器表:
Get-NetIPInterface -AddressFamily IPv4 | Sort-Object -Property InterfaceMetric -Descending
您希望您的主适配器(在我的情况下是 wifi)具有最低的InterfaceMetric。
Set-NetIPInterface -InterfaceAlias 'Wi-Fi' -InterfaceMetric 1
有关更多信息,请参阅此 github 线程: https ://github.com/docker/for-win/issues/2760#issuecomment-430889666
推荐阅读
- google-drive-api - Google GDoc - 没有可用的预览
- node.js - 使用 querySelectorAll,在某些情况下如何捕获属性,在其他情况下如何捕获整个元素?
- r - 如何使用数据框列表列表
- jquery - 选择由 Jquery .load 创建的 div
- python - TfidfVectorizer.fit_transfrom 和 tfidf.transform 有什么区别?
- docusignapi - 如何使用 SDK 上传大文件进行签名
- c++ - C++蛮力攻击函数不返回结果
- database-design - 需要帮助进行 3NF 分解
- swift - 为什么在使用前置摄像头时,我的人脸检测框会反方向移动?
- android - 在 ANDROID 中,如何将值传递给具有打开套接字连接的后台线程