ubuntu 启动docker报错 System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
时间: 2024-06-04 21:05:34 浏览: 18
这个错误信息是由于 Docker 需要 systemd 来启动,但是 Ubuntu 系统中并没有启动 systemd。解决这个问题需要执行以下步骤:
1. 首先,确认一下你的 Ubuntu 版本。如果你的 Ubuntu 版本是 15.04 或者更老的版本,那么你需要升级到 16.04 或者更高版本。
2. 确认你已经安装了 systemd-sysv 包。如果没有安装,可以通过以下命令安装:
```
sudo apt-get update
sudo apt-get install systemd-sysv
```
3. 重启系统。重启后,系统会默认使用 systemd 作为 init 系统。
4. 启动 Docker。现在,你应该可以正常启动 Docker 了。
相关问题
docker中System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
在Docker中出现"System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down"的错误通常是因为容器内部没有运行systemd作为init系统。Docker容器默认使用的是轻量级的init系统,而不是完整的systemd。
这个错误可能会出现在尝试在容器内运行systemd相关命令或服务时。由于容器内没有systemd,所以无法连接到systemd总线。
解决这个问题的方法有两种:
1. 使用其他方式来管理容器内的服务,而不是依赖于systemd。可以考虑使用supervisord、runit等工具来管理容器内的进程。
2. 如果确实需要在容器内运行systemd,可以通过修改Dockerfile来实现。具体步骤如下:
- 在Dockerfile中添加以下内容:
```
# Enable systemd
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
```
- 构建镜像并运行容器:
```
docker build -t myimage .
docker run -it --privileged --name mycontainer myimage
```
- 这样就可以在容器内运行systemd了。
希望以上信息对您有帮助!如果还有其他问题,请随时提问。
docker System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
docker报错"System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down"的原因是因为系统没有使用systemd作为init系统。解决这个问题的方法是使用以下命令启动docker服务:sudo service docker start。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)