Using the Systemctl Command in a Container in a Kubernetes Environment

Asked 1 years ago, Updated 1 years ago, 105 views

Thank you for your help.

I'd like to use the Systemctl command in the container in the pod managed by Kubernetes.
It will be rejected as follows:

#systemctl
Failed to get D-Bus connection—Operation not permitted

Can't we deal with it with something like the --priviled option, just like the Docker command?
Currently using the Master and multiple nodes to build the environment, I logged in to the node, typed the Docoker command directly, and executed the following command with the --priviled option on the target container, but got the same error:

 sudo docker exec-it -- privileged container name/bin/bash

# systemctl
Failed to get D-Bus connection—Operation not permitted

What I want to do is
I would like to put nginx in Centos, which I created as Deployment, curl the service from the outside, crush the container, and try functions such as auto-healing.
I wish I could build containers such as Nginx from the beginning, but I would like to use other commands, so I would like to put Nginx in the CentOS environment and check it.

Thank you for your cooperation.

docker kubernetes

2022-09-29 22:35

2 Answers

Your container is not set up to use systemd.
You should pull docker.io/centos/systemd to start /usr/sbin/init.

(Reference) https://hub.docker.com/_/centos/


2022-09-29 22:35

I would like to put nginx in Centos that I created as Deployment, curl the service from the outside, crush the container, and try features such as auto-healing.

In this case, if you do kubectl delete pod, kubectl proxy svc/your-service, and curl at hand, you will be able to do the same thing, but would that be okay?


2022-09-29 22:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.