docker: umask mounted host volume...
by masavini from LinuxQuestions.org on (#4S5TV)
hi,
is there a way to mount a host volume into a docker container so that it is seen as owned by root instead of a normal user?
this is what i mean...
let's touch a file:
Code:$ echo $USER
teo
$ id -u
1000
$ id -g
1000
$ mkdir /tmp/test
$ touch /tmp/test/t
$ ls -l /tmp/test/t
-rw-rw-r-- 1 teo teo 0 Oct 9 12:47 /tmp/test/t... so far so good.
not let's mount /tmp/test as a host volume in a simple docker container and run the same ls -l command:
Code:$ docker run --rm -v /tmp/test:/tmp/test alpine:3.7 ls -l /tmp/test/t
-rw-rw-r-- 1 1000 1000 0 Oct 9 10:39 /tmp/test/tquestion is:
is there a way to mount /tmp/test so that file t looks owned by container's root user and the output of the last command looks like this?
Code:-rw-rw-r-- 1 root root 0 Oct 9 10:39 /tmp/test/tthanks!


is there a way to mount a host volume into a docker container so that it is seen as owned by root instead of a normal user?
this is what i mean...
let's touch a file:
Code:$ echo $USER
teo
$ id -u
1000
$ id -g
1000
$ mkdir /tmp/test
$ touch /tmp/test/t
$ ls -l /tmp/test/t
-rw-rw-r-- 1 teo teo 0 Oct 9 12:47 /tmp/test/t... so far so good.
not let's mount /tmp/test as a host volume in a simple docker container and run the same ls -l command:
Code:$ docker run --rm -v /tmp/test:/tmp/test alpine:3.7 ls -l /tmp/test/t
-rw-rw-r-- 1 1000 1000 0 Oct 9 10:39 /tmp/test/tquestion is:
is there a way to mount /tmp/test so that file t looks owned by container's root user and the output of the last command looks like this?
Code:-rw-rw-r-- 1 root root 0 Oct 9 10:39 /tmp/test/tthanks!