docker运行debian12系统systemctl命令错误解决办法
- 开发技术
- 2023-11-23
- 414
- 0
在docker中debian容器执行systemctl命令出现下面错误:
System has not been booted with systemd as init system (PID 1). Can’t operate.
Failed to connect to bus: Host is down
解决办法参考下面内容
1、创建Dockerfile文件内容
FROM debian:12
RUN apt-get update && apt-get install -y runit systemd-sysv
CMD ["/sbin/init"]
2、执行镜像打包
docker build -t debian:systemctl .
3、创建容器
docker run -itd --privileged=true --name debian12 debian:systemctl