.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 lineUSER $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传入
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?