最佳实践页面提到了以下内容:(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/GID有什么意义?在什么情况下,允许系统分配UID/GID不能提供足够的安全性?
显式指定这些值似乎会导致显式指定值(UID/GID)已经在使用的情况。
发布于 2018-09-10 20:26:37
我认为,对于某些人可能依赖于特定的数字uid,可能会将数据注入容器的情况,这一点更有意义。
# 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" datahttps://stackoverflow.com/questions/52264775
复制相似问题