繁体   English   中英

使用 Visual Studio 2017 构建 Docker 失败,因为使用私有 nuget 源在 dotnet 还原期间超时

[英]Docker build with Visual Studio 2017 failed because timeout during dotnet restore using private nuget feed

I have a ASP.NET Core api for which I want to build a Docker image using VisualStudio 2017. I used Add Docker Support -> Linux and it generated the Dockerfile, and as I want to use a NuGet.Config file, I modified it consequently ( COPY NuGet.Config.) 我在 dotnet 恢复期间使用 NuGet.Config 文件,如下所示:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY NuGet.Config ./
COPY ["Stock.Api/Stock.Api.csproj", "Stock.Api/"]
COPY ["Business/Stock/Stock.csproj", "Business/Stock/"]
COPY ["Business/Stock.Dto/Stock.Dto.csproj", "Business/Stock.Dto/"]
RUN dotnet restore --configfile NuGet.Config "Stock.Api/Stock.Api.csproj"
COPY . .
WORKDIR "/src/Stock.Api"
RUN dotnet build "Stock.Api.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Stock.Api.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Stock.Api.dll"]

And here is the NuGet.Config file I use which has two NuGet feeds, a public https://api.nuget.org/v3/index.json and a LOCAL private feed http://192.168.40.100:3000/nuget ( 192.168.40.100 是我的本地@IP)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
     <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
     <add key="MYPRIVATEFEED" value="http://192.168.40.100:3000/nuget" />
   </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>

使用 VS2017,我尝试构建 Docker 映像,它在 dotnet restore 期间的第 10 步超时失败,如您所见:

Step 10/19 : RUN dotnet restore --configfile NuGet.Config     "Stock.Api/Stock.Api.csproj"
3> ---> Running in 5c8827a8d62d
3>  Restoring packages for /src/Business/Stock/Stock.csproj...
3>  Retrying 'FindPackagesByIdAsyncCore' for source 'http://192.168.40.100:3000/nuget/FindPackagesById()?id='Dto.Base'&semVerLevel=2.0.0'.
3>  The HTTP request to 'GET http://192.168.40.100:3000/nuget/FindPackagesById()?id='Dto.Base'&semVerLevel=2.0.0' has timed out after 100000ms.

我不知道为什么会出现超时,因为本地提要在我的本地计算机中。 我修改了 DNS 使用 Docker for Desktop 自动到 static,我尝试了很多我在互联网上找到的东西,但没有任何成功。

有人有线索吗?

非常感谢

有兴趣的朋友,遇到同样的问题,我终于卸载了Docker,重新安装,重新设置,一切如常……需要看看Docker网络是如何工作的……

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM