Docker容器内的dotnet还原错误-权限被拒绝



我使用本教程将我的asp.net核心应用程序放入Docker容器中

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

但在容器内获得许可被拒绝:

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

我在Windows10机器上和Jenkins Build Server上都尝试过,结果是一样的。

我不明白nuget是作为哪个用户运行的?

有人能帮忙吗?

在dockerfile 中添加以下行

USER root

我的容器中的问题是用户不是root用户,不幸的是,dotnet恢复需要root访问权限。

最新更新