【问题标题】:dotnet restore with private nuget server fails in docker-compose使用私有 nuget 服务器的 dotnet restore 在 docker-compose 中失败
【发布时间】:2021-03-16 16:03:30
【问题描述】:

dotnet restore 步骤仅在 docker-compose 中失败,并且仅在我使用除公共服务器之外的私有 nuget 服务器时失败。它似乎在我的私人服务器上寻找公共包,然后超时。我收到此错误:

#15 101.5   The HTTP request to 'GET http://my-nuget/Shared/nuget/FindPackagesById()?id='Microsoft.EntityFrameworkCore.Design'&semVerLevel=2.0.0' has timed out after 100000ms.

当我手动运行 dotnet restore 时没有问题,它没有在 docker 中。我在两个都使用私有和公共 nuget 服务器的项目上遇到了问题。另一个项目只使用公共服务器,它可以正常工作(并且它没有 nuget.config)。

我的 nuget.config 是:

<configuration>
    <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="USAS" value="http://my-nuget/Shared/nuget" />
    </packageSources>
</configuration>

如果我删除我的私人服务器,我会收到三个使用私人服务器的包的错误,但我没有收到公共包的错误。

【问题讨论】:

    标签: docker docker-compose nuget-package dotnet-restore


    【解决方案1】:

    在你的 Dockerfile 中 dotnet restore 之后添加私有服务器 url,如下所示:

    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
    ...
    
    RUN dotnet restore "Application.csproj" -s "YOUR PRIVATE NUGET SERVER URL"
    ...
    
    

    【讨论】:

      【解决方案2】:

      尝试删除 docker 网络。就我而言,它有所帮助。
      docker network prune - 删除所有未使用的网络

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-08
        • 2018-02-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-25
        相关资源
        最近更新 更多