我们有一个Dockerfile
,其中包含格式如下的命令
RUN dotnet restore --no-cache -s http://localhost:8081/repository/nuget-hosted/
运行时
docker build .
此行遇到的错误是
Retrying 'FindPackagesByIdAsyncCore' for source 'http://localhost:8081/repository/nuget-repo-name/FindPackagesById()?id='Package.Name''.
An error occurred while sending the request.
Couldn't connect to server
/usr/share/dotnet/sdk/2.1.101/NuGet.targets(104,5): error : Failed to retrieve information about 'Package.Name' from remote source 'http://localhost:8081/repository/nuget-repo-name/FindPackagesById()?id='Package.Name''.
但是,当我们在命令行上运行同一命令时,dotnet restore
成功。
有问题的nuget服务器在同一台计算机上运行。如果我们在浏览器中点击相同的URL,那就成功了。
我们如何在docker build
中访问在localhoat:8081运行的nuget服务器,以便成功创建docker映像?
答案 0 :(得分:0)