Docker Community Forums

Share and learn in the Docker community.

Mount volume on shared filesystem

(Spencerimp) #1


I have encountered permission issues when mounting my project directory to Docker container.

Suppose my project is at /home/spencer/myproj/
and the image name is ubuntu

The following command works fine on my laptop.

$cd /home/spencer/myproj
$docker run -v `pwd`:/home/spencer/myproj -it ubuntu

However, when I used this command on a cluster node, which uses a file system shared among several nodes, I got permission denied error.

$cd /home/spencer/myproj
$docker run -v `pwd`:/home/spencer/myproj -it ubuntu
docker: Error response from daemon: mkdir /home/spencer/myproj: permission denied.

I also tried to do the following commands to cope with the SElinux issues

$setenforce 0
$docker run -v `pwd`:/home/spencer/myproj:Z -it ubuntu
$docker run --privileged=true -v `pwd`:/home/spencer/myproj:Z -it ubuntu
$docker run --privileged=true -u root -v `pwd`:/home/spencer/myproj:Z -it ubuntu

But still got the same permission error.

Then I tried to mount the my directory instead of the proj

$docker run --privileged=true -u root -v /home/spencer:/home/spencer/:Z -it ubuntu

This time I can mount it. However, I cannot access the my directory in the container. So I checked the permission in the container

root@3584b4c02747:/home# ls -l
total 34
d--------- 24 root 282394938 889 Nov 10 09:27 spencer

I also checked my directory on the host machine

$ ls -l /home
total 68
d--------- 24 root [some group name]  889 Nov 10 10:27 spencer
d--------- 30 root [some group name]  xxx Nov 10 10:27 otherusers

It seems that the issues might be due to the permission of the host file system. I can access my own directory without any problem on the host, but cannot even enter it in the container. Does anyone have solution/suggestion for this?

Thanks in advance!

The OS on our cluster node is
Red Hat Enterprise Linux Server release 7.2 (Maipo)
I am not in the sudoer list, but I can ask the administrator to help me if I can provide some solutions.