无法在 Ubuntu 18.04 上安装 docker-ce

无法在 Ubuntu 18.04 上安装 docker-ce

我按照官方说明在 Ubuntu 上安装 Docker,但在尝试安装 docker-ce 包时总是失败,并显示以下输出:

$ sudo apt install docker-ce
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aufs-tools cgroupfs-mount docker-ce-cli 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 31 not upgraded.
Need to get 0 B/65,6 MB of archives.
After this operation, 293 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package pigz.
(Reading database ... 485946 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.7~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce-cli (5:19.03.7~3-0~ubuntu-bionic) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_5%3a19.03.7~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce (5:19.03.7~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.7~3-0~ubuntu-bionic) ...
Setting up pigz (2.4-1) ...
Setting up docker-ce (5:19.03.7~3-0~ubuntu-bionic) ...
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
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: activating (auto-restart) (Result: exit-code) since Wed 2020-03-11 11:58:51 CET; 5ms ago
     Docs: https://docs.docker.com
  Process: 28828 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 28828 (code=exited, status=1/FAILURE)
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) ...
Processing triggers for systemd (237-3ubuntu10.39) ...
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)

命令的输出systemctl status docker.service如下:

● docker.service
   Loaded: not-found (Reason: No such file or directory)
   Active: failed (Result: exit-code) since Wed 2020-03-11 11:59:00 CET; 29min ago
 Main PID: 30256 (code=exited, status=1/FAILURE)

Mär 11 11:58:58 filipovic-nb systemd[1]: docker.service: Failed with result 'exit-code'.
Mär 11 11:58:58 filipovic-nb systemd[1]: Failed to start Docker Application Container Engine.
Mär 11 11:59:00 filipovic-nb systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Mär 11 11:59:00 filipovic-nb systemd[1]: docker.service: Scheduled restart job, restart counter is at 4.
Mär 11 11:59:00 filipovic-nb systemd[1]: Stopped Docker Application Container Engine.
Mär 11 11:59:00 filipovic-nb systemd[1]: docker.service: Start request repeated too quickly.
Mär 11 11:59:00 filipovic-nb systemd[1]: docker.service: Failed with result 'exit-code'.
Mär 11 11:59:00 filipovic-nb systemd[1]: Failed to start Docker Application Container Engine.

最后几行journalctl -xe是:

Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #7 0x7ffe715dba50 b   resource:///org/gnome/gjs/modules/signals.js:128 (0x7f2d785d2230 @ 386)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #8 0x5619e46f1240 i   resource:///org/gnome/shell/ui/messageTray.js:479 (0x7f2d7819ef78 @ 22)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #9 0x7ffe715dc6a0 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #10 0x5619e46f11c0 i   resource:///org/gnome/shell/ui/calendar.js:801 (0x7f2d781ad3c8 @ 22)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #11 0x7ffe715dd290 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #12 0x7ffe715dd360 b   self-hosted:918 (0x7f2d785f12b8 @ 394)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: == Stack trace for context 0x5619e435d330 ==
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #0 0x5619e46f1480 i   resource:///org/gnome/shell/ui/messageTray.js:236 (0x7f2d7819e4d8 @ 42)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #1 0x7ffe715d8f80 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #2 0x5619e46f13e0 i   resource:///org/gnome/shell/ui/messageTray.js:812 (0x7f2d781a14d8 @ 28)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #3 0x7ffe715d9b60 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #4 0x5619e46f1340 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:100 (0x7f2d780483c8 @ 42)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #5 0x7ffe715da740 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #6 0x5619e46f12c8 i   resource:///org/gnome/shell/ui/windowAttentionHandler.js:44 (0x7f2d78043e68 @ 17)
Mär 11 12:25:26 filipovic-nb gnome-shell[2097]: g_object_run_dispose: assertion 'G_IS_OBJECT (object)' failed
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #7 0x7ffe715dba50 b   resource:///org/gnome/gjs/modules/signals.js:128 (0x7f2d785d2230 @ 386)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #8 0x5619e46f1240 i   resource:///org/gnome/shell/ui/messageTray.js:479 (0x7f2d7819ef78 @ 22)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #9 0x7ffe715dc6a0 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #10 0x5619e46f11c0 i   resource:///org/gnome/shell/ui/calendar.js:801 (0x7f2d781ad3c8 @ 22)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #11 0x7ffe715dd290 I   resource:///org/gnome/gjs/modules/_legacy.js:82 (0x7f2d785b5de0 @ 71)
Mär 11 12:25:26 filipovic-nb org.gnome.Shell.desktop[2097]: #12 0x7ffe715dd360 b   self-hosted:918 (0x7f2d785f12b8 @ 394)
Mär 11 12:25:26 filipovic-nb gnome-shell[2097]: Object Gio.Settings (0x5619ef5e5ab0), has been already deallocated - impossible to access it. This might be caused by the object having been destroyed from C code 
Mär 11 12:25:26 filipovic-nb gnome-shell[2097]: g_object_run_dispose: assertion 'G_IS_OBJECT (object)' failed

我在网上找到的所有答案都无济于事。有人知道我该怎么做才能解决这个问题吗?

答案1

您可以通过运行以下命令来修复此问题:

  1. sudo apt-get update
  2. sudo apt-get install ca-certificates curl gnupg lsb-release
  3. sudo mkdir -p /etc/apt/keyrings
  4. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  5. echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  6. sudo apt update
  7. sudo apt-get install docker-ce

更多信息请点击这里:在 Ubuntu 上安装 Docker 引擎

相关内容