无法在WSL上从Ubuntu卸载Docker

Eck*_*cki 4 docker ubuntu-16.04 windows-subsystem-for-linux

我正在尝试卸载Docker,但总是收到错误消息。我已经在互联网上进行搜索,但未能成功修复该错误。我印象中有一些破损的软件包,但对于Linux来说,我通常是新手。结果如下:

sudo apt-get purge -y docker-ce 
                                                                                                                                                 1 ? Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  docker-ce*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 181 MB disk space will be freed.
(Reading database ... 44147 files and directories currently installed.)
Removing docker-ce (18.03.1~ce-0~ubuntu) ...
invoke-rc.d: could not determine current runlevel
 * Stopping Docker: docker                                                                                                                                                                                      start-stop-daemon: warning: failed to kill 466: No such process
No process in pidfile '/var/run/docker-ssd.pid' found running; none killed.
invoke-rc.d: initscript docker, action "stop" failed.
dpkg: error processing package docker-ce (--purge):
 subprocess installed pre-removal script returned error exit status 1
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

我希望有人能帮助我。:)

mah*_*y67 10

尝试从WSL中删除docker.io时,我也遇到了同样的错误,这显然是预先安装的。问题在于,由于Docker从未运行,因此删除前脚本失败,因此无法停止。

在我的情况下,我对/var/lib/dpkg/info/docker.io.prerm进行了sudo编辑,并将/sbin/stop docker其(失败)替换为true(仅返回成功)。在那之后,apt remove docker.io运行完美。

(我在这里找到了解决方案,这是2013年以来的一个老问题:如果从未使用过Docker,则无法将其卸载(Ubuntu)

  • 问题是 Docker 当前假设如果 init 脚本存在,则守护进程必须正在运行。话虽这么说,目前`.prerm`文件的唯一目的是停止`docker`,所以你可以删除`/var/lib/dpkg/info/docker-ce.prerm`,然后正常卸载。 (2认同)