首页 > 解决方案 > docker build 失败并显示以下消息

问题描述

[build-env 5/7] RUN dotnet restore:
#12 1.506   Determining projects to restore...
#12 48.75 /usr/share/dotnet/sdk/5.0.401/NuGet.targets(131,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/app/OptimizerContainerAPI.csproj]
#12 48.75 /usr/share/dotnet/sdk/5.0.401/NuGet.targets(131,5): error :   The SSL connection could not be established, see inner exception. [/app/OptimizerContainerAPI.csproj]
#12 48.75 /usr/share/dotnet/sdk/5.0.401/NuGet.targets(131,5): error :   The remote certificate is invalid because of errors in the certificate chain: PartialChain [/app/OptimizerContainerAPI.csproj]

以下是我的 Dockerfile 中的片段

#Get base image for the .Net Core from Microsoft
FROM mcr.microsoft.com/dotnet/sdk:5.0 as build-env
WORKDIR /app

#copy the CSPROJ files and restore any dependicies
COPY *.csproj ./
COPY NuGet.Config ./
RUN dotnet restore


#Copy the project files and build our release
COPY . ./
RUN dotnet publish -c Release -o out


#Generate Runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
EXPOSE 80
COPY  --from=build-env /app/out .

ENTRYPOINT [ "dotnet", "OPTIMIZERCONTAINERAPI.dll"]

标签: asp.netdockernuget

解决方案


推荐阅读