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

最近升级.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.

Important

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

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

 

 
posted @   风海迷沙  阅读(225)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示