Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet restore error inside Docker-Container - permission denied

I used this tutorial to put my asp.net Core Application inside a Docker Container

https://code.visualstudio.com/docs/containers/quickstart-aspnet-core

But get an permission Denied inside the container:

10:39:02  /usr/share/dotnet/sdk/3.1.201/NuGet.targets(124,5): error : Access to the path '/src/obj' is denied. [/src/Lankoon.csproj]
10:39:02  /usr/share/dotnet/sdk/3.1.201/NuGet.targets(124,5): error :   Permission denied [/src/Lankoon.csproj]
10:39:02  The command '/bin/sh -c dotnet restore "./Lankoon.csproj"' returned a non-zero code: 1

I tried it on a Windows10 Machine and also on an Jenkins Build Server, the result is the same.

I don't understand as which user the nuget is running?

Can anyone help?

like image 555
Christian Avatar asked Sep 03 '25 10:09

Christian


1 Answers

Add the following line to you dockerfile

USER root

The problem inside my container was that the user was not root and dotnet restore unfortunately need root access.

like image 79
Christian Avatar answered Sep 05 '25 00:09

Christian