Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant uninstall Docker from Ubuntu on WSL

I am trying to uninstall Docker but I always get an Error. I already searched in the internet but wasnt succesful to fix the error. I have the impression there are some broken packages but I am very new to Linux in general. This is the result:

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)

I hope anybody can help me with that. :)

like image 976
Ecki Avatar asked Jul 17 '18 09:07

Ecki


1 Answers

I had this same error trying to remove docker.io from WSL, which is apparently preinstalled. The problem is that the pre-removal script is failing because docker has never run, and therefore it cannot be stopped.

In my case I sudo-edited /var/lib/dpkg/info/docker.io.prerm and replaced /sbin/stop docker (which was failing) with true (which simply returns success). After that, apt remove docker.io worked perfectly.

(I found the solution here, an old problem from 2013: docker can't be uninstalled if it never worked (Ubuntu))

like image 176
Alcamtar Avatar answered Oct 20 '22 09:10

Alcamtar