我将Visual Studio中的docker support(Windows)添加到了asp.net核心项目中。它在调试模式下运行良好。但是在“发布”模式下显示以下错误。我尝试切换到其他网络(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.