linux - Docker mount a volume as root -
the problem description
i have docker image, being executed volume mounting options large number of times. built in way default user not have root permissions. need make sure when mount volume being mounted root
, not current working user because of security concerns. (the current working non-root user must not allowed delete files inside mounted volume.)
example
from host machine:
docker run -it -v /path/to/mount:/container/mounting/path image-name
inside container current-user@docker-container
:
all of files inside /container/mounting/path
must have owner permissions root root
, not current-user current-user
.
just make sure permissions on /path/to/mount
set root:root
, should good.
like example, i'm mounting /sbin has root:root permissions on local machine.
current-user@hostmachine:/sbin$ docker run -it -v /sbin:/home/sbin centos:6.6 /bin/bash [root@e9e21b0f36c7 /]# [root@e9e21b0f36c7 ~]# adduser current-user [root@e9e21b0f36c7 ~]# su current-user - [current-user@e9e21b0f36c7 root]$ cd [current-user@e9e21b0f36c7 home]$ cd sbin [current-user@e9e21b0f36c7 sbin]$ touch file touch: cannot touch `file': permission denied [current-user@e9e21b0f36c7 sbin]$
Comments
Post a Comment