Docker: System has not been booted with systemd as init system

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

如:systemctl start keepalived.service

Docker: System has not been booted with systemd as init system

 

 这是因为启动容器命令如下:

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

解决办法是更换启动命令:
docker run -tid --name centos_1 --privileged=true centos:latest /sbin/init
区别在于后面用了 /sbin/init

两种区别目前不确定,但是表象如下:使用/bin/bash或不指定命令的启动的可以使用docker attach 容器名 命令登录容器,使用了/sbin/init 的则不能,必须使用docker exec 命令访问
上一篇:Linux运维一定要知道的服务管理!


下一篇:systemd - 服务