gpt4 book ai didi

docker - docker build 中的 Dotnet 还原失败

转载 作者:行者123 更新时间:2023-12-04 02:28:49 25 4
gpt4 key购买 nike

您好,我正在尝试 dockerize ASP NET Core 2.1应用程序和 docker build执行时失败 dotnet restore .
我已经针对这个特定问题检查了其他线程 Nuget connection attempt failed "Unable to load the service index for source" .

那里提供的解决方案对我没有帮助。

Dockerfile

ARG serverPath=./Core/Server

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app


COPY ./Core/Server/*.csproj ./
RUN dotnet restore //fails here

COPY ./Core/Server/ ./
RUN dotnet publish -c Release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet","Server.dll"]

docker build 的输出
$ docker build -t server .
Sending build context to Docker daemon 11.13MB
Step 1/11 : ARG serverPath=./Core/Server
Step 2/11 : FROM microsoft/dotnet:sdk AS build-env
---> 343e2dc38168
Step 3/11 : WORKDIR /app
---> Using cache
---> e9b75480ecb9
Step 4/11 : COPY ./Core/Server/*.csproj ./
---> Using cache
---> 2de864bedf6a
Step 5/11 : RUN dotnet restore
---> Running in 2fc6963e7e2c
Restoring packages for /app/Server.csproj...
/usr/share/dotnet/sdk/2.2.100/NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/app/Server.csproj]
/usr/share/dotnet/sdk/2.2.100/NuGet.targets(114,5): error : The SSL connection could not be established, see inner exception. [/app/Server.csproj]
/usr/share/dotnet/sdk/2.2.100/NuGet.targets(114,5): error : Authentication failed because the remote party has closed the transport stream. [/app/Server.csproj]
The command '/bin/sh -c dotnet restore -p:RestoreUseSkipNonexistentTargets=false -nowarn:msb3202,nu1503' returned a non-zero code: 1

最佳答案

尝试这个

docker network ls

这应该列出 networkIDs 尝试运行 docker build
docker build --network=<networkid> tag=<tag>

尝试上面列出的所有网络,它将与一个网络一起工作,那就是主机网络。

关于docker - docker build 中的 Dotnet 还原失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53704874/

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