问题

docker内进行systemctl等命令时,出现错误。

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=true/sbin/init
后面/bin/bash需要替换为/sbin/init

即由此方式:

 docker run -tid --name test centos  /bin/bash

变更为:

 docker run -tid --name test --privileged=true  centos  /sbin/init
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐