linux - docker build 无法连接到 http 服务器,即使它可以在命令行上访问

标签 linux docker .net-core-2.0 nuget-server

我们有一个 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,则成功。

我们如何使运行在 localhoat:8081 的 nuget 服务器在 docker build 中可访问,以便成功创建 docker 镜像?

最佳答案

关于linux - docker build 无法连接到 http 服务器,即使它可以在命令行上访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50952004/

相关文章:

python - 如何在没有包的情况下在python中创建makefile

java - 访问 Dockerfile 中的上下文之外

docker - Gitlab CI 将环境变量传递给 docker build

asp.net-core-mvc - GetExternalLoginInfoAsync 返回 null dotnet core 2.0

c# - 检测 .net 核心 2.0

linux - 如何终止 webshel​​l 上的 ping?

java - 如何使用shell调用java方法?

asp.net-core - 在构建 WebHost 之前访问托管环境

linux - 多次运行脚本并将输出保存在多个文件夹中

build - 构建Docker镜像时,包含文件的默认位置是什么?