(使用 WSL ubuntu 应用程序)系统尚未使用系统作为 init 系统(PID 1)启动。无法操作

jam*_*910 6 ubuntu docker windows-subsystem-for-linux

我是 Ubuntu 的第一个用户。我在 wmware 中安装 Ubuntu 失败,所以我在微软应用商店安装了 Ubuntu 应用程序,一切都很好。但是,当我插入关闭或暂停命令来关闭我的 ubuntu 电源时,我不断收到“系统尚未作为初始化系统(PID 1)启动的系统”。无法操作”错误消息。

我尝试通过此链接(https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/)使用 docker,但在多次进入第 2 进程后失败. 我不确定我的失败是因为安装了 docker 收费箱而不是正常的收费箱。(我的电脑只是 windows 10。不是 windows pro)

我想我必须尝试其他的东西。如果你不介意我问,我怎么能解决这个问题?

(还有一个。如果我只是单击右侧顶部的“X”按钮,与使用“halt”或“shutdown”命令关闭 Ubuntu 有什么不同?

谢谢

小智 15

基于此:https ://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/

systemd 现已在 WSL 版本 0.67.6 或更高版本中提供。

启用:

打开命令提示符:

# CHOOSE option A or B:
# A. check your version and ensure it is 0.67.6 or higher
wsl.exe --version
# B. run WSL update if the version is low
wsl.exe --update
Run Code Online (Sandbox Code Playgroud)

打开 WSL 提示符:

sudo nano /etc/wsl.conf
Run Code Online (Sandbox Code Playgroud)

将其添加到 wsl.conf 并保存文件:

[boot]
systemd=true
Run Code Online (Sandbox Code Playgroud)

返回命令提示符:

# warning: this will kill any shells/processes you have running!
wsl.exe --shutdown
Run Code Online (Sandbox Code Playgroud)


kin*_*gaj 7

我发现这很有用:https : //linuxhandbook.com/system-has-not-been-booted-with-systemd/

就我而言

# start docker using systemctl
sudo systemctl docker start 
# returns: 
# 
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Run Code Online (Sandbox Code Playgroud)

基本建议是:

# check if your system is using `systemd` or `sysvinit`
ps -p 1 -o comm=
Run Code Online (Sandbox Code Playgroud)

如果命令没有返回systemd,在我的情况下,WSL 上的 Ubuntu-20.04,命令返回init,然后使用命令模式

# start services using sysvinit
service docker start
Run Code Online (Sandbox Code Playgroud)

这对我有用。

  • “service docker start”为我返回“docker:无法识别的服务” (18认同)