Is it possible to use 'systemctl' in pod?

10/12/2018

I made an image using dockerfile. And I created pod from the image that I created. But an error has occurred. When I get a shell to pod and used 'systemctl', I got a D-bus error. How can I solve this problem?

Failed to get D-Bus connection: Operation not permitted
-- K.k
centos7
dbus
kubernetes
systemctl

1 Answer

10/12/2018

You basically can't use systemctl in Docker, since containers don't run the systemd daemon. This is tricky to run in Docker itself, and the couple of workarounds that could make it go are difficult-to-impossible to express in Kubernetes.

You should come up with some other way to run your process. Usually a container will only run a single service, and so instead of starting it via a systemd unit file you can just run the service directly; your Dockerfile might end with something like

CMD ["/usr/sbin/myserviced", "--foreground"]
-- David Maze
Source: StackOverflow