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

2021/4/10 18:41:40

本文主要是介绍Docker: System has not been booted with systemd as init system,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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

如:systemctl start keepalived.service

 

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

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 命令访问


这篇关于Docker: System has not been booted with systemd as init system的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程