在docker 容器里使用systemctl命令报错

如:systemctl start keepalived.service

System has not been booted with systemd as init system

问题原因:

我启动centos容器的命令是:

docker run -d --name centos_1 -it  centos:latest /bin/bash

需要修改为

docker run -tid --name centos_1 --privileged=true centos:latest /sbin/init

也就是加--privileged=true,修改/binbash  为/sbin/init

修改后,就可以正常启动服务了

System has not been booted with systemd as init system

 

 

相关文章: