环境centos7.8
docker容器使用systemctl命令报错:
[root@d7a74069b83c yum.repos.d]# systemctl status firewalld System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
solution:
启动容器时加入参数 --privileged
[root@localhost ~]# docker run -itd --name c8 --privileged centos /usr/sbin/init 6a6a3c9f9fa9acc59d62a6e82ccb6a637db8aada004aa8a096c6061108c6b144 [root@localhost ~]# docker exec -it c8 /bin/bash
在CentOS 7.8环境下,当尝试在Docker容器内使用systemctl命令管理firewalld服务时,遇到了错误提示:'System has not been booted with systemd as init system (PID 1). Can't operate.' 和 'Failed to connect to bus: Host is down'。解决方案是在启动Docker容器时添加--privileged参数,如:`docker run -it --name c8 --privileged centos /usr/sbin/init`。之后,可以正常进入容器并使用systemctl命令。
4万+

被折叠的 条评论
为什么被折叠?



