gpt4 book ai didi

Docker dotnet 恢复 "Unable to load the service index for source https://api.nuget.org/v3/index.json."

转载 作者:行者123 更新时间:2023-12-02 19:56:38 29 4
gpt4 key购买 nike

我在 Visual Studio 中将 docker 支持(Windows)添加到了一个 asp.net 核心项目。它在 Debug模式下运行良好。但在“发布”模式下显示如下错误。我尝试切换到不同的网络(4G 上的热点),但仍然显示相同的错误消息。

下面是生成的 docker 文件。

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1809 AS build
WORKDIR /src
COPY ["BlankSite/BlankSite.csproj", "BlankSite/"]
RUN dotnet restore "BlankSite/BlankSite.csproj"
COPY . .
WORKDIR "/src/BlankSite"
RUN dotnet build "BlankSite.csproj" -c Release -o /app

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

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

错误信息:
>Step 7/18 : RUN dotnet restore "BlankSite/BlankSite.csproj"
1> ---> a406dac3ca1d
1> ---> Running in 38089ed5e181
1>C:\Program Files\dotnet\sdk\2.2.300\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\BlankSite\BlankSite.csproj]
1>C:\Program Files\dotnet\sdk\2.2.300\NuGet.targets(121,5): error : No such host is known [C:\src\BlankSite\BlankSite.csproj]
1>The command 'cmd /S /C dotnet restore "BlankSite/BlankSite.csproj"' returned a non-zero code: 1
1>C:\Users\vincentliao\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.7.9\build\Container.targets(196,5): error CTP1001: An error occurred while attempting to build Docker image.

最佳答案

您的容器无法访问 Internet。要解决此问题,请关注 this .如果您不需要互联网访问,您可以设置一个私有(private)存储库而不是 nuget.org。

关于Docker dotnet 恢复 "Unable to load the service index for source https://api.nuget.org/v3/index.json.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57474520/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com