Kubernetes 是否可以使用';systemctl';在吊舱里?

Kubernetes 是否可以使用';systemctl';在吊舱里?,kubernetes,centos7,dbus,systemctl,Kubernetes,Centos7,Dbus,Systemctl,我用dockerfile制作了一个图像。我根据我创建的图像创建了pod。 但是发生了一个错误。当我得到一个外壳到pod并使用“systemctl”时,我得到了一个D-bus错误。我怎样才能解决这个问题 Failed to get D-Bus connection: Operation not permitted 您基本上不能在Docker中使用systemctl,因为容器不运行systemd守护进程。这在Docker本身中运行是很棘手的,并且可能使其运行的两个变通方法很难在Kubernetes

我用dockerfile制作了一个图像。我根据我创建的图像创建了pod。 但是发生了一个错误。当我得到一个外壳到pod并使用“systemctl”时,我得到了一个D-bus错误。我怎样才能解决这个问题

Failed to get D-Bus connection: Operation not permitted

您基本上不能在Docker中使用
systemctl
,因为容器不运行
systemd
守护进程。这在Docker本身中运行是很棘手的,并且可能使其运行的两个变通方法很难在Kubernetes中表达出来

您应该想出一些其他方法来运行流程。通常一个容器只运行一个服务,因此您可以直接运行服务,而不是通过systemd单元文件启动它;您的Dockerfile可能以以下内容结尾

CMD ["/usr/sbin/myserviced", "--foreground"]