作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最佳实践页面提到以下内容:
(https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user)
Consider an explicit UID/GID
Users and groups in an image are assigned a non-deterministic UID/GID in that the “next” UID/GID is assigned regardless of image rebuilds. So, if it’s critical, you should assign an explicit UID/GID."
最佳答案
我认为这对于某人可能依赖于特定数字 uid 的情况更为重要,可能是将数据注入(inject)容器中。
# this needs to be readable by the container process
# it runs as non-root user "www-data"
# we think its uid is 18
sudo chown -R 18 data
sudo docker run -v ./data:/data -p 8888:80 imagename
adduser
使 uid 变成别的东西,这样的配方会中断(主机无法直接查看容器的
/etc/passwd
文件以了解实际的 uid 将是什么)。
# may or may not work to get the uid
CONTAINER_UID=$(sudo docker run --rm imagename id -u)
sudo chown -R "$CONTAINER_UID" data
关于docker - 在 Dockerfile 中使用显式 UID/GID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52264775/
我是一名优秀的程序员,十分优秀!