Failed to get D-Bus connection: No such file or directory

when running centos7 image in docker, error
[[email protected] /]# systemctl list-units
Failed to get d-bus connection: No such file or directory
d-bus allows the program to register on it to provide services to other programs. It also provides the possibility for the client program to query what services are available. Applications can also be registered to wait for kernel events, such as hardware hotplug. It is a three-tier inter-process communication (IPC) system, including:
function library libdbus, used for calling contacts and interacting messages between two applications. A message constructed based on libdbus, the bus daemon can connect to multiple applications simultaneously and can route messages from one application to 0 or more other programs. A series of Wrapper libraries based on specific application frameworks. D-bus is designed for two specific situations:
communication between two desktop applications within the same desktop session, allowing the desktop session to be integrated as a whole to solve problems related to the process lifecycle. Communication between a desktop session and an operating system, where the operating system generally includes the kernel and system daemons.
after the docker exit
$docker run — br> $docker run –privileged/ti-e “container=docker” centos7-base /usr/sbin/init
-privileged docker introduction, using this parameter, the root in the container has the real root privilege, otherwise, the root in the container is just an external ordinary user privilege. The container that the Privileged starts can see a lot of equipment on host and mount can be performed.
even allows you to start a docker container in a docker container. -e “container=docker” sets the environment variable that processes inside the container can get directly.
can now execute the systemctl command

/root @ bd5aa199dbc9 ~ # systemctl status SSHD
low SSHD. Service – the OpenSSH server daemon
the Loaded: the Loaded (/ usr/lib/systemd/system/SSHD. Service; enabled; Vendor pre: enabled)
Active: inactive (dead)
Docs: man: SSHD (8)

Read More: