docker 构建失败并显示以下消息

问题描述 投票:0回答:1
[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.net docker nuget
1个回答
0
投票

我的私有 NuGet 源之一遇到了类似的问题,但在 Dockerfile 中手动添加 NuGet 源和凭据(而不是提供 Nuget.Config 文件)后,它对我有用。

#Restore dependencies
RUN dotnet nuget add source https://nuget.pkg.github.com/XXXX/index.json -n github --username XXXX --password XXXX --store-password-in-clear-text
RUN dotnet restore 
© www.soinside.com 2019 - 2024. All rights reserved.