简体   繁体   中英

Figuring out Docker host volume permissions

I am trying to run a gocd server docker image and facing file permissions issues. Can't seem to figure out what I am missing.

Found out what uid/gid is being used in the container:

]$ sudo docker container run gocd/gocd-server:v21.1.0 id
$ exec /usr/local/sbin/tini -g -- id
uid=1000(go) gid=0(root) groups=0(root)
[centos@ip-10-0-0-168 ~]$ 

Created a folder on the local host and set ownership:

$ sudo mkdir -p /gocd/data
[centos@ip-10-0-0-168 ~]$ sudo chown -R 1000:0 /gocd/
[centos@ip-10-0-0-168 ~]$ 
[centos@ip-10-0-0-168 ~]$ ls -l /
total 16
lrwxrwxrwx.   1 root   root    7 Feb 29  2020 bin -> usr/bin
:
drwxr-xr-x.   3 centos root   18 Feb  8 15:55 gocd
:

Docker run:

$ sudo docker run  -v /gocd/data/:/godata -p 8153:8153 gocd/gocd-server:v21.1.0
/docker-entrypoint.sh: Creating directories and symlinks to hold GoCD configuration, data, and logs
$ mkdir -v -p /godata/artifacts
mkdir: can't create directory '/godata/artifacts': Permission denied
/docker-entrypoint.sh: cannot mkdir -v -p /godata/artifacts
[centos@ip-10-0-0-168 ~]$ 

Ok, so instead of chown -R 1000:00 /gocd , I switched to chown -R 1000:root and with that I was able to get the container to start.

Though in both cases the output of ls -l shows the same user and group:

drwxr-xr-x.   3 centos root   18 Feb  9 01:36 gocd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM