Reputation: 712
On RHEL, CentOS, Fedora, and other SELinux-enabled distributions, creating a docker image with mounts and turned-on SELinux returns permission denied:
docker run --rm -it -v $(pwd):/home centos7
[root@4b348767653c ~]# ls /home
ls: cannot open directory /home: Permission denied
How do I continue using Docker images with mounted volumes without turning off SELinux?
Upvotes: 1
Views: 1193
Reputation: 712
Use special flag :Z
to mount your volumes, for example:
docker run --rm -it -v $(pwd):/home:Z centos7
[root@4b348767653c ~]# ls /home
Documents Downloads ...
For more information about SELinux contexts, see thePractical SELinux and Containers blog.
Upvotes: 1