.net8.0 在docker下发布镜像的坑


/app/Upload$ >1.txt
bash: 1.txt: Permission denied

 7.0是没有这个问题的,根据官方说法:.NET 8.0 Container Images Now Available · dotnet/dotnet-docker · Discussion #4995 · GitHub

New Features for .NET Container Images

Non-Root User Included By Default

The .NET Linux container images include a new non-root user named app with the UID 1654.
The UID is provided in an environment variable, $APP_UID.
You can opt into this new user by adding the line USER $APP_UID to your Dockerfile.


The name of this user may conflict with an existing user defined by your application's Dockerfile.

简单点的解决方案:docker run 时加上参数 --user 0,把root或想要的用户UID传入


posted @ 2023-12-13 21:41  风海迷沙  阅读(122)  评论(0编辑  收藏  举报