【问题标题】:Docker container receives permission denied in mountsDocker 容器在挂载中收到权限被拒绝
【发布时间】:2019-02-13 04:05:57
【问题描述】:

在 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 映像?

【问题讨论】:

    标签: docker centos rhel selinux


    【解决方案1】:

    使用特殊标志:Z 挂载您的卷,例如:

    docker run --rm -it -v $(pwd):/home:Z centos7
    [root@4b348767653c ~]# ls /home
    Documents Downloads ...
    

    有关 SELinux 上下文的更多信息,请参阅Practical SELinux and Containers 博客。

    【讨论】:

    • 然而,根据您的链接,适当的标志似乎是:z,而不是:Z
    • @ErikMD 好吧,对于多个容器,:z 它是。对于单个容器,:Z 是。此外,这些 SELinux 上下文的更改不应该在重启 afaik 后持续存在 :)
    猜你喜欢
    • 2023-03-19
    • 2016-03-30
    • 2019-01-06
    • 1970-01-01
    • 2020-09-07
    • 1970-01-01
    • 2022-01-12
    • 2018-10-31
    • 2018-12-15
    相关资源
    最近更新 更多