当在Dokcer容器中使用systemctl时报以下错误
1 | System has not been booted with systemd as init system (PID 1). Can't operate. |
问题原因:
启动容器时执行的启动是/bin/bash,没有相应的权限调用内核程序,需要在run修改相应的指令获得权限
解决办法
在run指令后加—privileged=true,修改/bin/bash 为/sbin/init
1 | docker run --privileged=true -itd xxxxx /sbin/init |
进入容器时使用的是docker exec -it xxxxx /bin/bash