使用相同的Docker映像文件权限因计算机而异 [英] Using the same Docker image file permissions differ from machine to machine
问题描述
我有一个问题,我根本无法掌握.我在主节点上的Docker容器中运行Jenkins管道.现在,我添加了另一个节点,并希望在那里也运行管道.
I have a problem, that I cannot grasp at all. I'm running my Jenkins pipeline in a Docker container on the master node. Now I added another node and want to run the pipeline there as well.
但是,使用同一张图片,我在容器中获得了不同的文件权限:
However, using the same image I get different file permissions in the container:
### master
> docker image ls node:10.20.1-stretch
REPOSITORY TAG IMAGE ID CREATED SIZE
node 10.20.1-stretch c5f1efe092a0 13 days ago 912MB
> docker run --rm -ti -u 1000:1000 node:10.20.1-stretch ls -la /home/node
total 20
drwxr-xr-x 2 1000 1000 4096 May 15 20:31 .
drwxr-xr-x 3 0 0 4096 May 15 20:31 ..
-rw-r--r-- 1 1000 1000 220 May 15 2017 .bash_logout
-rw-r--r-- 1 1000 1000 3526 May 15 2017 .bashrc
-rw-r--r-- 1 1000 1000 675 May 15 2017 .profile
### node 1
> docker image ls node:10.20.1-stretch
REPOSITORY TAG IMAGE ID CREATED SIZE
node 10.20.1-stretch c5f1efe092a0 13 days ago 912MB
> docker run --rm -ti -u 1000:1000 node:10.20.1-stretch ls -la /home/node
total 20
drwxr-xr-x 2 0 0 4096 May 26 05:42 .
drwxr-xr-x 1 0 0 4096 May 26 05:42 ..
-rw-r--r-- 1 0 0 220 May 26 05:42 .bash_logout
-rw-r--r-- 1 0 0 3526 May 26 05:42 .bashrc
-rw-r--r-- 1 0 0 675 May 26 05:42 .profile
我观察到/tmp
目录的类似行为,该目录在主目录上具有 chmod 1777
,在节点1上具有 1755
.
I observed a similar behavior for the /tmp
directory, which has chmod 1777
on master and 1755
on node 1.
# master
> docker -v
Docker version 19.03.9, build 9d988398e7
> dockerd -v
Docker version 19.03.9, build 9d988398e7
# node 1
> docker -v
Docker version 19.03.10, build 9424aeaee9
> dockerd -v
Docker version 19.03.10, build 9424aeaee9
我认为错误的行为是在 node 1
上,因为/home/node
目录及其所有子级都归 root:root
,但同一目录由主服务器上的 node:node
拥有.但是,我已经将节点1上的Docker版本从19.03.8升级到19.03.10,没有任何改变.
I assume the wrong behavior is on node 1
, as the /home/node
directory and all of its children are owned by root:root
there, but the same directory is owned by node:node
on the master. However, I already upgraded the Docker version on node 1 from 19.03.8 to 19.03.10 and nothing changed.
关于Docker容器,我有什么不了解的地方吗?我已经与他们合作了一段时间,但从未观察到这种行为.
It there anything I don't understand about Docker containers? I have been working with them for a while, but never observed such a behavior.
推荐答案
我将存储驱动程序从 overlay2
更改为 aufs
.现在,我拥有正确的权限.
I have change the storage driver from overlay2
to aufs
. Now I have the correct permissions.
这篇关于使用相同的Docker映像文件权限因计算机而异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!