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


起因是這樣:我當前已進入Docker容器里面,在容器的操作系統(centos7)使用systemctl命令的時候,出錯了,錯誤信息:System has not been booted with systemd as init system (PID 1). Can't operate.

如:systemctl status keepalived

 

問題原因:

我啟動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命令了

 

 

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM