dotnet恢复在本地工作,但在构buildDocker容器时失败

如果我使用dotnet classlib -lang f# -o hello-docker创build一个新的控制台应用程序, cd进入目录,然后运行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):错误:无法parsing主机名[/hello/hello-docker.fsproj]
命令“/ bin / sh -c dotnet restore”返回一个非零的代码:1

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