【问题标题】:Selinux problems with pod binded directorypod绑定目录的selinux问题
【发布时间】:2022-10-18 22:27:04
【问题描述】:

我想在 podman pod 容器中绑定目录。当我尝试像这样绑定它时:

...
    - name: project-root
      hostPath:
        path: ../.
        type: Directory
...
      volumeMounts:
        - name: project-root
          mountPath: /project

我无法在容器中访问它。它也不适用于 root 权限。 当我在系统上关闭 selinux 时,它可以正常工作。使用普通的容器命令,我可以使用...:Z 标志来摆脱这个错误,但我不知道如何在 pod 文件中处理它。

【问题讨论】:

    标签: kubernetes containers kubernetes-pod podman


    【解决方案1】:

    在底层主机上创建的文件或目录只能由 root 写入。您要么需要在 privileged Container 中以 root 身份运行您的进程,要么修改主机上的文件权限以便能够写入 hostPath 卷。

    通过创建目录并将所有权更改为 Kubernetes。这是标准的,它也在官方文档中给出。

    请查看此document 了解更多信息

    【讨论】:

      猜你喜欢
      • 2017-03-21
      • 1970-01-01
      • 2014-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-01
      • 2012-09-17
      相关资源
      最近更新 更多