无法获得 D-Bus 连接:以非 root 用户身份从 docker 运行 systemctl 时没有此类文件或目录

无法获得 D-Bus 连接:以非 root 用户身份从 docker 运行 systemctl 时没有此类文件或目录

我正在尝试以非 root 用户身份运行基于 centos+python3 的 docker 容器,然后尝试从容器获取主机服务的 systemctl 状态。

docker run --user=3001:3001 --userns=host -ti -v /run/systemd:/run/systemd --pid=host centos-python:latest /bin/bash

Failed to get D-Bus connection: No such file or directory我运行时收到错误systemctl status httpd.service

而当我以 root 用户身份运行时,我会获得在主机中正确运行的服务的 systemctl 状态。

是否需要执行任何额外的卷安装才能以非 root 用户身份运行,或者是否无法以非 root 用户身份获取 systemctl 状态

相关内容