dotnet restore在本地工作但在构建Docker容器时失败

时间:2017-09-26 20:32:51

标签: docker .net-core windows-10

如果我使用dotnet classlib -lang f# -o hello-dockercd创建一个新的控制台应用程序到目录中,然后运行dotnet restore,那么一切都按预期工作。

但是,如果我添加Dockerfile以及以下内容

FROM microsoft/dotnet:2-sdk

WORKDIR /hello

COPY hello-docker.fsproj .
COPY *.fs ./

RUN dotnet restore

RUN dotnet build

ENTRYPOINT [ "dotnet", "run" ]

并运行docker build .,它无法通过以下消息到达nuget.org

  

/usr/share/dotnet/sdk/2.0.0/NuGet.targets(102,5):错误:无法加载源https://api.nuget.org/v3/index.json的服务索引。 [/hello/hello-docker.fsproj]
  /usr/share/dotnet/sdk/2.0.0/NuGet.targets(102,5):错误:发送请求时发生错误。 [/hello/hello-docker.fsproj]
  /usr/share/dotnet/sdk/2.0.0/NuGet.targets(102,5):错误:无法解析主机名[/hello/hello-docker.fsproj]
  命令' / bin / sh -c dotnet restore'返回非零代码:1

为什么我可以在本地恢复,但不能在Docker容器内恢复?

0 个答案:

没有答案