Docker Community Forums

Share and learn in the Docker community.

Dotnet restore fails when building in docker container

Issue type
I set up a docker container in order to build a C# project in it.
When performing docker restore, when it tries to pull the external NuGet packages, for every package i get

Retrying ‘FindPackagesByIdAsync’ for source ‘https://[…]/nuget/v3/flat2/microsoft.extensions.fileproviders.abstractions/index.json’.
Resource temporarily unavailable

This is the case for packages from private, as well as from public sources.

When doing docker restore --disable-parallel it works without any problems, but takes 20 minutes to build that small project.

I already followed
https://success.docker.com/article/how-to-reserve-resource-temporarily-unavailable-errors-due-to-tasksmax-setting but this did not have an effect.

OS Version/build
Note: I am running Ubuntu 20.04 within HyperV on the latest Windows 10 version. Inside this Ubuntu, Docker is installed (there is a reason for doing so).
Apart from the described error, the Internet connection inside the Ubuntu VM works totally fine (I anyway have the feeling, that this error is not related to the Internet connection itself).
When pulling a large file from the Internet from inside a Docker container using e.g. wget, it takes my entire bandwith.

dev@Ubuntu-dev:~$ uname -a
Linux Ubuntu-dev 5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

App version

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-focal

dev@Ubuntu-dev:~$ docker --version
Docker version 3.0.11+azure, build eb310fca49568dccd87c6136f774ef6fff2a1b51

dev@Ubuntu-dev:~$ docker version
Client:
Version: 3.0.11+azure
API version: 1.40
Go version: go1.12.17
Git commit: eb310fca49568dccd87c6136f774ef6fff2a1b51
Built: Tue Mar 3 21:59:52 2020
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 3.0.11+azure
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: aa6a9891b0
Built: Tue Mar 10 18:53:36 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

dev@Ubuntu-dev:~$ cat /etc/docker/daemon.json
{
“dns”: [“8.8.8.8”]
}

Steps to reproduce

(needed to wipe away some project specifics and had to “damage” the links with spaces due to new users policy)
Dockerfile:

FROM mcr. microsoft. com/dotnet/core/sdk:3.1-focal AS build
ARG PAT=#{System.AccessToken}#
ARG CONFIGURATION=Debug
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
“{“endpointCredentials”: [{“endpoint”:“https://[…]nuget/v3/index.json”, “password”:”$PAT"}, {“endpoint”:“https://[…]/nuget/v3/index.json”, “password”:"$PAT"}]}"
ENV NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS 60
ENV NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS 60
RUN curl -L https:// raw. githubusercontent. com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
WORKDIR /app
COPY […] ./[…]
WORKDIR ./[…]
RUN dotnet restore
RUN dotnet publish -c $CONFIGURATION -o out

BTW: dotnet restore directly on the Ubuntu host works with any problems.

Does anybody have an idea what I can try in order to fix this issue?

Maybe worth mentioning:
When I start the container “mcr.microsoft.com/dotnet/core/sdk:3.1-focal” manually and do exactly the same steps as in the Dockerfile manually, it also works fine.

I have really no clue.