在 RHEL、CentOS、Fedora 和其他支持 SELinux 的发行版上,创建带有挂载和开启 SELinux 的 docker 镜像返回权限被拒绝:
docker run --rm -it -v $(pwd):/home centos7
[root@4b348767653c ~]# ls /home
ls: cannot open directory /home: Permission denied
如何在不关闭 SELinux 的情况下继续使用带有挂载卷的 Docker 镜像?
最佳答案
使用特殊标志 :Z
来挂载您的卷,例如:
docker run --rm -it -v $(pwd):/home:Z centos7
[root@4b348767653c ~]# ls /home
Documents Downloads ...
有关 SELinux 上下文的更多信息,请参阅 Practical SELinux and Containers博客。
关于Docker 容器收到挂载中被拒绝的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52228696/