Docker容器使用问题:Failed to get D-Bus connection
场景 Docker容器安装CentOS Linux release 7.9.2009 (AltArch),运行命令,提示出错 [root@atlas800 init.d]# service mysql start Failed to get D-Bus connection: Operation not permitted [root@atlas800 init.d]# firewall-cmd --zone=public --list-ports Error: DBUS_ERROR: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory 网上说明 原因:在centos7的docker容器里面不能用service启动服务。报这个错的原因是dbus-daemon没能启动。systemctl并不是不能使用。将CMD或者entrypoint设置为/usr/sbin/init即可。docker容器会自动将dbus等服务启动起来。 Docker的设计理念是在容器里面不运行后台服务,容器本身就是宿主机上的一个独立的主进程,也可以间接的理解为就是容器里运行服务的应用进程。一个容器的生命周期是围绕这个主进程存在的,所以正确的使用容器方法是将里面的服务运行在前台。再说到systemd