Redhat SELilnux – Docker – volume – permission denied

I have a folder like this:

total 4.0K
-rwxrwx---. 1 root vboxsf 101 Dec 25 08:03 notes.txt
drwxrwx---. 1 root vboxsf 64 Dec 24 22:43 test
drwxrwx---. 1 root vboxsf 64 Dec 25 07:45 test2

Then I run a docker

sudo docker run -i -v /Data:/Data ubuntu bash

cd /Data
mkdir test3

I got permission denied.

After some research, it turned out that this related to SELinux, it’s a security feature to limit root access. You can easily identify this by looking at the dot (.) at the end of the listing.

You can temporary disable it by using:

su -c "setenforce 0"

To make it permanent run this:

chcon -Rt svirt_sandbox_file_t /Data

With docker 1.7 , you can use the option “:z”

docker run -v /Data:/Data:z rhel7 /bin/sh

Leave a Reply

Your email address will not be published. Required fields are marked *