Tag Archives: Systemctl

The docker container reports an error when using the systemctl command

I have seen many solutions, but they are not friendly to novices and are not particularly clear

Error content:  

        System has not been booted with systemd as init system (PID 1). Can’t operate.
        Failed to connect to bus: Host is down

 

Solution:

      docker run -itd    –privileged –name myCentos centos /usr/sbin/init

      After creation: use the following command to enter the container

      docker exec -it myCentos /bin/bash

      Pay special attention to the bold content and don’t forget

      The reason is that/bin/Bash is executed in the first step by default, and systemctl cannot be used because of a bug in docker  

                      Therefore, we use/usr/SBIN/init and — privileged, so that we can use systemctl, but override the default/bin/bash

        Therefore, if we want to enter the container, we can no longer use docker attach mycentos  

        Instead, you can only use    docker exec -it myCentos /bin/bash   Because exec allows us to execute the overridden default command/bin/bash  

        At the same time -it is also necessary

        Similar to Ubuntu, the init directory may be different

Of course, I don’t know the specific bug. I hope it will be fixed in the future

 

Centos Systemctl Error getting authority: Error initializing authority: Error calling StartServ…

 

[root@iZbp1he0bdge2g92l9fjnxZ ~]# systemctl  restart  zabbix-agent
Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: Timeout was reached (g-io-error-quark, 24)
Failed to restart zabbix-agent.service: Connection timed out
See system logs and 'systemctl status zabbix-agent.service' for details.

When installing the service using centos 7.4 an error was reported.

Error reported when starting zabbix.

Centos using Systemctl reports Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: Timeout was reached (g-io-error-quark, 24)

Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: Timeout was reached (g-io-error-quark, 24)

Solution:

ps -ef |grep polkit

Reinstall:
 pyum reinstall polkit

Restart
reboot