Docker Build 镜像Nuget资源无法访问
1.现象
[root@localhost NetCoreDockerMicroService]# docker build -t core31microservice -f Dockerfile . --network=host ##创建镜像
出现问题:无法连接到https://api.nuget.org/v3/index.json.这个是Nuget的资源文件
/usr/share/dotnet/sdk/3.1.410/NuGet.targets(128,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/src/MicroService.ServiceInstance/MicroService.ServiceInstance.csproj]
/usr/share/dotnet/sdk/3.1.410/NuGet.targets(128,5): error : The SSL connection could not be established, see inner exception. [/src/MicroService.ServiceInstance/MicroService.ServiceInstance.csproj]
/usr/share/dotnet/sdk/3.1.410/NuGet.targets(128,5): error : Unable to read data from the transport connection: Connection reset by peer. [/src/MicroService.ServiceInstance/MicroService.ServiceInstance.csproj]
用IE打开https://api.nuget.org/v3/index.json.也无法打开;说明这个资源有问题;打开VS 中nuget包源设置,设置没问题。
2.解决
自己解决方式:点击更新,在IE中多刷新几次https://api.nuget.org/v3/index.json. 发现URL自动跳转到了https://nuget.cdn.azure.cn/v3/index.json
并且IE返回信息,然后立即Build镜像,然后成功了。可能的问题是nuget 资源服务器不稳定或者自己网络不稳定引起的。
其他人解决方式:.添加新的包源 “http://packages.nuget.org/v1/FeedService.svc/” 重新跟新项目中的包文件