如何卸载docker-engine?

时间:2015-10-06 15:45:24

标签: docker

我已经用

安装了docker
curl -sSL https://get.docker.com/ | sh

当我尝试卸载软件包时,我面临以下错误

$ sudo apt-get remove docker-engine
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  docker-engine
0 upgraded, 0 newly installed, 1 to remove and 5 not upgraded.
1 not fully installed or removed.
After this operation, 28.5 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 454135 files and directories currently installed.)
Removing docker-engine (1.8.2-0~vivid) ...
Failed to stop docker.service: Unit docker.service not loaded.
invoke-rc.d: initscript docker, action "stop" failed.
dpkg: error processing package docker-engine (--remove):
 subprocess installed pre-removal script returned error exit status 5
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 docker-engine
E: Sub-process /usr/bin/dpkg returned an error code (1)

我如何卸载docker包?

我使用的是Ubuntu 15.04。

5 个答案:

答案 0 :(得分:27)

试一试

sudo mv /var/lib/dpkg/info/{packagename}.* /tmp/
sudo dpkg --remove --force-remove-reinstreq {packagename}
sudo apt-get remove {packagename}
sudo apt-get autoremove && sudo apt-get autoclean

答案 1 :(得分:6)

我遇到了同样的问题,但是在Ubuntu 14.04中。我解决这个问题的方法是:

首先删除不良链接:

sudo mv /var/lib/dpkg/info/{packagename}.* /tmp/
sudo apt-get remove {packagename}

所以现在你可以再次安装它:

sudo apt-get install docker-engine

多数人。

答案 2 :(得分:2)

看起来不像Docker特定的问题,而是像一般的安装问题。

Docker是否曾在该计算机上工作(例如:安装是否成功?)

我会开始研究Failed to stop docker.service: Unit docker.service not loaded,看看是否会导致更多关于出错的见解。好像它无法停止服务。

您可能需要阅读一些关于systemd的内容,我建议this页面。 journalctl也可能有用,请参阅here

然后:

  • docker.service存在吗?
  • 可以加载吗?
  • 它的地位是什么?
  • 如果你开始它会怎么说?
  • 停止吗?

ps:不是全自动安装脚本的忠实粉丝。我不明白apt-get install docker-engine ...

的错误

答案 3 :(得分:1)

如果您想删除Docker Toolbox附带的所有内容包括Docker Engine )。

您可以执行此shell脚本:

#!/bin/bash

# Uninstall Script

if [ "${USER}" != "root" ]; then
    echo "$0 must be run as root!"
    exit 2
fi

while true; do
  read -p "Remove all Docker Machine VMs? (Y/N): " yn
  case $yn in
    [Yy]* ) docker-machine rm -f $(docker-machine ls -q); break;;
    [Nn]* ) break;;
    * ) echo "Please answer yes or no."; exit 1;;
  esac
done

echo "Removing Applications..."
rm -rf /Applications/Docker

echo "Removing docker binaries..."
rm -f /usr/local/bin/docker
rm -f /usr/local/bin/docker-machine
rm -r /usr/local/bin/docker-machine-driver*
rm -f /usr/local/bin/docker-compose

echo "Removing boot2docker.iso"
rm -rf /usr/local/share/boot2docker

echo "All Done!"

如果你仍然有折旧的 Boot2docker ,你也想要摆脱它。

您可以通过执行以下shell脚本来卸载它:

#!/bin/bash

# Uninstall Script

if [ "$(which boot2docker)" == "" ]; then
    echo "boot2docker does not exist on your machine!"
    exit 1
fi

if [ "${USER}" != "root" ]; then
    echo "$0 must be run as root!"
    exit 2
fi

echo "Stopping boot2docker processes..."
boot2docker stop && boot2docker delete

echo "Removing boot2docker executable..."
rm -f /usr/local/bin/boot2docker

echo "Removing boot2docker ISO and socket files..."
rm -rf ~/.boot2docker
rm -rf /usr/local/share/boot2docker

echo "Removing boot2docker SSH keys..."
rm -f ~/.ssh/id_boot2docker*

echo "Removing boot2docker OSX files..."
rm -f /private/var/db/receipts/io.boot2docker.*
rm -f /private/var/db/receipts/io.boot2dockeriso.*

echo "Removing Docker executable..."
rm -f /usr/local/bin/docker

echo "All Done!"

答案 4 :(得分:1)

问题是Docker试图在卸载时自行停止,而您实际上从未成功运行过它,因此它没有运行。看看/var/lib/dpkg/info/docker-ce.prerm。看起来像这样:

#!/bin/sh
set -e
# Automatically added by dh_installinit/12.1.1
if [ -x "/etc/init.d/docker" ]; then
        invoke-rc.d docker stop || exit 1
fi
# End automatically added section

您可以在此处轻松发现逻辑漏洞:它假设存在init脚本,则docker守护程序必须正在运行。但是,如果您将其安装在实际上不能正常工作的平台上(例如WSL等),

由于prerm脚本唯一的作用就是停止docker,并且确保docker在您的系统上没有运行,因此只需删除文件,之后您就可以像apt remove docker-ce一样正常。