Skip to content

Commit

Permalink
Add content src/site/notes/CloudNative/docker/docker build/更改基础镜像用户id.md
Browse files Browse the repository at this point in the history
  • Loading branch information
1024daniel committed Dec 30, 2024
1 parent f2dd618 commit d3b9e76
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
{"dg-publish":true,"permalink":"/CloudNative/docker/docker build/更改基础镜像用户id/","noteIcon":"3"}
---

#dockerfile #docker
```dockerfile
# 使用基础镜像
FROM base-image:latest

# 切换到 root 用户
USER root

# 修改用户和组的 UID 和 GID
RUN groupmod -g 1001 HwHiAiUser && \
usermod -u 1001 -g 1001 HwHiAiUser

# 修复整个文件系统中属于旧 UID/GID 的文件权限
RUN find / -path /proc -prune -o -user 1000 -exec chown -h 1001 {} + && \
find / -path /proc -prune -o -group 1000 -exec chgrp -h 1001 {} +

# 切换回非 root 用户(如果需要)
USER HwHiAiUser

# 继续其他构建步骤

```

0 comments on commit d3b9e76

Please sign in to comment.