Docker 无法在 Ubuntu 16.04 上正确安装(或运行)

Docker 无法在 Ubuntu 16.04 上正确安装(或运行)

下面是我按照 digitalocean 的指南操作时的终端输出https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04

它使用 docker 存储库,因此理论上它应该可以工作,但实际上却不能。

当尝试配置时,似乎出现 dpkg 错误。

有没有办法解决此错误以便正确安装?

wayne@dscience:~$ apt-cache policy docker-ce
docker-ce:
  Installed: (none)
  Candidate: 17.06.0~ce-0~ubuntu
  Version table:
     17.06.0~ce-0~ubuntu 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.2~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.1~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     17.03.0~ce-0~ubuntu-xenial 500
        500 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
wayne@dscience:~$ sudo apt-get install -y docker-ce
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libhardware2 libhybris libhybris-common1 libmedia1 libwxbase3.0-0v5
  libwxgtk3.0-0v5 linux-headers-4.8.0-36 linux-headers-4.8.0-36-generic
  linux-headers-4.8.0-46 linux-headers-4.8.0-46-generic
  linux-headers-4.8.0-49 linux-headers-4.8.0-49-generic
  linux-headers-4.8.0-52 linux-headers-4.8.0-52-generic
  linux-headers-4.8.0-54 linux-headers-4.8.0-54-generic
  linux-headers-4.8.0-56 linux-headers-4.8.0-56-generic
  linux-headers-4.8.0-58 linux-headers-4.8.0-58-generic
  linux-image-4.8.0-36-generic linux-image-4.8.0-46-generic
  linux-image-4.8.0-49-generic linux-image-4.8.0-52-generic
  linux-image-4.8.0-54-generic linux-image-4.8.0-56-generic
  linux-image-4.8.0-58-generic linux-image-extra-4.8.0-36-generic
  linux-image-extra-4.8.0-46-generic linux-image-extra-4.8.0-49-generic
  linux-image-extra-4.8.0-52-generic linux-image-extra-4.8.0-54-generic
  linux-image-extra-4.8.0-56-generic linux-image-extra-4.8.0-58-generic
  snap-confine
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  aufs-tools cgroupfs-mount
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount docker-ce
0 upgraded, 3 newly installed, 0 to remove and 321 not upgraded.
Need to get 20.6 MB of archives.
After this operation, 96.5 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 cgroupfs-mount all 1.2 [4,970 B]
Get:3 https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce amd64 17.06.0~ce-0~ubuntu [20.5 MB]
Fetched 20.6 MB in 35s (575 kB/s)                                             
Selecting previously unselected package aufs-tools.
(Reading database ... 556325 files and directories currently installed.)
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.2_all.deb ...
Unpacking cgroupfs-mount (1.2) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_17.06.0~ce-0~ubuntu_amd64.deb ...
Unpacking docker-ce (17.06.0~ce-0~ubuntu) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for systemd (229-4ubuntu17) ...
Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
Setting up cgroupfs-mount (1.2) ...
Setting up docker-ce (17.06.0~ce-0~ubuntu) ...
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 Tue 2017-08-08 12:35:25 CDT; 9ms ago
     Docs: https://docs.docker.com
  Process: 13306 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=1/FAILURE)
 Main PID: 13306 (code=exited, status=1/FAILURE)

Aug 08 12:35:25 dscience systemd[1]: Failed to start Docker Application Co...e.
Aug 08 12:35:25 dscience systemd[1]: docker.service: Unit entered failed state.
Aug 08 12:35:25 dscience systemd[1]: docker.service: Failed with result 'e...'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package docker-ce (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu17) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
wayne@dscience:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: 
   Active: inactive (dead) (Result: exit-code) since Tue 2017-08-08 12:35:31 CD
     Docs: https://docs.docker.com
  Process: 13731 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=1/FAI
 Main PID: 13731 (code=exited, status=1/FAILURE)

Aug 08 12:35:31 dscience systemd[1]: Failed to start Docker Application Contain
Aug 08 12:35:31 dscience systemd[1]: docker.service: Unit entered failed state.
Aug 08 12:35:31 dscience systemd[1]: docker.service: Failed with result 'exit-c
Aug 08 12:35:31 dscience systemd[1]: docker.service: Service hold-off time over
Aug 08 12:35:31 dscience systemd[1]: Stopped Docker Application Container Engin
Aug 08 12:35:31 dscience systemd[1]: docker.service: Start request repeated too
Aug 08 12:35:31 dscience systemd[1]: Failed to start Docker Application Contain
lines 1-14/14 (END)

答案1

首先尝试重新安装...

sudo apt purge docker-ce && sudo apt install docker-ce

如果这不起作用,请采取更积极的措施(删除现有的 docker 配置)...

sudo apt purge docker-ce && sudo apt install docker-ce

以上是命令行尝试复制对我真正有用的方法,即在 Synaptic 包管理器中Mark for Complete Removal(在包上docker-ce) - 然后重新安装,也在 Synaptic 中。

相关内容