Using the same Docker image file permissions differ from machine to machine

旧街凉风 提交于 2021-02-11 15:41:09

问题


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

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

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.

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.


回答1:


I have change the storage driver from overlay2 to aufs. Now I have the correct permissions.



来源:https://stackoverflow.com/questions/62087914/using-the-same-docker-image-file-permissions-differ-from-machine-to-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!