意外关机后无法在 Ubuntu 上安装 Docker

意外关机后无法在 Ubuntu 上安装 Docker

这是我的第一个问题,所以我希望我问的是正确的。我在 VirtualBox VM 中运行 docker(客户操作系统是 Ubuntu 18.04)

bink@bink-VirtualBox:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:    18.04
Codename:   bionic

前几天,我遇到了一次“计划外重启”(即电源故障),这肯定损坏了一些文件,因为 docker 服务将无法启动。我尝试修复和修复 docker,最终按照以下说明卸载了 docker:如何彻底卸载docker

之后,我按照以下标准说明从头开始重新安装了docker:https://docs.docker.com/engine/install/ubuntu/

在安装的最后一步,我收到一些错误,请参见:

bink@bink-VirtualBox:/var/lib$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree       
Reading state information... Done
containerd.io is already the newest version (1.2.13-2).
The following additional packages will be installed:
  aufs-tools cgroupfs-mount pigz
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount docker-ce docker-ce-cli pigz
0 upgraded, 5 newly installed, 0 to remove and 27 not upgraded.
Need to get 63.8 kB/63.9 MB of archives.
After this operation, 282 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6,320 B]
Fetched 63.8 kB in 0s (268 kB/s)          
Selecting previously unselected package pigz.
(Reading database ... 186105 files and directories currently installed.)
Preparing to unpack .../archives/pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../aufs-tools_1%3a4.9+20170918-1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:4.9+20170918-1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.4_all.deb ...
Unpacking cgroupfs-mount (1.4) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../docker-ce-cli_5%3a19.03.12~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce-cli (5:19.03.12~3-0~ubuntu-bionic) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_5%3a19.03.12~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce (5:19.03.12~3-0~ubuntu-bionic) ...
Setting up aufs-tools (1:4.9+20170918-1ubuntu1) ...
Setting up cgroupfs-mount (1.4) ...
Setting up docker-ce-cli (5:19.03.12~3-0~ubuntu-bionic) ...
Setting up pigz (2.4-1) ...
Setting up docker-ce (5:19.03.12~3-0~ubuntu-bionic) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Job for docker.service canceled.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: deactivating (stop-sigterm)
     Docs: https://docs.docker.com
 Main PID: 23326 (dockerd)
    Tasks: 1
   CGroup: /system.slice/docker.service
           └─23326 [dockerd]

Aug 09 13:10:56 bink-VirtualBox systemd[1]: Starting Docker Application Container Engine...
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Processing triggers for systemd (237-3ubuntu10.41) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)

我怀疑在计划外重启时,containerd.io 出现了问题,但是当我运行 docker install 时,它说 containerd.io 已经是最新版本,所以它不会重新安装它。

如果我尝试 systemctl start docker,它只会返回Job for docker.service canceled.。但我实际上能够运行sudo dockerd并且 docker 将启动。我只是无法让它作为服务启动。

有人有什么建议吗?我搜索过这些错误,发现了一些略微相似的结果,但情况与我的情况并不完全相同。我只需要重新安装 containerd.io 吗?如果是这样,我该怎么做,因为系统认为它已经正确安装?

答案1

要找出 Docker 服务的问题所在,systemctl status docker.service或的输出journalctl -e可能会有所帮助。在 之后直接尝试这些命令systemctl start docker.service

要重新安装软件包,您可以使用sudo apt --reinstall install containerd.io或类似的方法。这里

但我会尝试找到服务无法启动的根本原因。它也可能修复其他问题,并且您可以从中学到更多

相关内容