起因是这样:我当前已进入Docker容器里面,在容器的操作系统(centos7)使用systemctl命令的时候,出错了,错误信息:System has not been booted with systemd as init system (PID 1). Can't operate.

如:systemctl status keepalived

Docker容器里使用systemctl命令报错(System has not been booted with systemd as init system)

 

问题原因:

我启动centos容器的命令是:

docker run -itd --name centos_java_nginx hejianliang/centos:java_nginx /bin/bash

需要改为:

docker run -itd --name centos_java_nginx --privileged=true hejianliang/centos:java_nginx /sbin/init

在原命令上加了 --privileged=true,修改/binbash  为 /sbin/init (重点)

修改过后,重新运行就可以在容器里正常使用systemctl命令了

Docker容器里使用systemctl命令报错(System has not been booted with systemd as init system)

 

 

 



相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-17
  • 2021-04-30
  • 2021-08-20
  • 2021-07-07
  • 2021-08-07
  • 2022-12-23
相关资源
相似解决方案