在 ubuntu 上构建 dotnet core 3.0 依赖项时资源暂时不可用

Resource temporarily unavailable when building dotnet core 3.0 dependency on ubuntu

提问人:user_0_found 提问时间:12/25/2019 更新时间:12/3/2021 访问量:7743

问:

我有一个 .net core 3.0 项目,我正在尝试对其进行 dockerise。调用的项目文件如下:SuperSecretProject.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <StartupObject>SuperSecretProject.Program</StartupObject>
    <UserSecretsId>cee96675-39d5-486b-bcca-9db409d1d0c4</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <DockerfileContext>.</DockerfileContext>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
  </ItemGroup>
</Project>

docker 文件为:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS debug

WORKDIR /build-debug
COPY ./SuperSecretProject.csproj ./
RUN dotnet restore

ENTRYPOINT ["echo", "hello"] 

但是,在构建时,我得到了 E.g. 给:Resource temporarily unavailable.docker build -f ./docker/Dockerfile . -t test

Step 4/5 : RUN dotnet restore
 ---> Running in d4ca119fa22c
  Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.extensions.logging.abstractions/index.json'.
  Resource temporarily unavailable
  Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/system.threading.tasks.extensions/index.json'.
  Resource temporarily unavailable
....

一些研究表明,docker 对它可以运行的任务数量有限制: https://success.docker.com/article/how-to-reserve-resource-temporarily-unavailable-errors-due-to-tasksmax-setting 但是这个修复程序似乎不起作用。

注意:如果将步骤 4 更改为 docker 映像,我可以成功构建 docker 映像,但对于较大的项目,构建时间变得太长。如果所有任务都可以并行完成,那就太好了。dotnet restore --disable-parallelasyncdotnet restore

docker ubuntu 异步 .net-core

评论

1赞 Shocked 7/16/2020
尝试使用 运行 docker build,例如--network=hostdocker build --network=host -f ./docker/Dockerfile . -t test
0赞 Sago78 3/29/2022
它对我设置 --network=bridge 有用,但是......我不明白原因

答:

0赞 silencej 12/3/2021 #1

重新启动 docker daemon 会有所帮助。

供参考:https://forums.docker.com/t/dotnet-restore-fails-when-building-in-docker-container/95386