Ubuntu 16.04 安装 Docker - Dependency failed for Docker Application Container

Docker 安装

由于 apt 官方库里的 Docker 版本可能比较旧,所以先卸载可能存在的旧版本:

sudo apt-get remove docker docker-engine docker-ce docker.io

在 Ubuntu 16.04 环境下可参考如下链接进行安装

https://blog.csdn.net/bingzhongdehuoyan/article/details/79411479

https://www.cnblogs.com/zyrblog/p/8523928.html

也可以直接按照如下方法安装:

# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

安装过程中遇到问题

在安装 Docker 的过程中,运行以下命令

sudo apt-get install docker-ce=18.06.0~ce~3-0~ubuntu

提示由于依赖项问题导致安装失败

..
..
dpkg: docker-ce-cli: dependency problems, but removing anyway as you requested:
 docker-ce depends on docker-ce-cli.
..
..

详细信息如下:

~/software$ sudo apt-get install docker-ce=18.06.0~ce~3-0~ubuntu
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  containerd.io linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  docker-ce-cli
The following packages will be DOWNGRADED:
  docker-ce
0 upgraded, 0 newly installed, 1 downgraded, 1 to remove and 163 not upgraded.
Need to get 40.1 MB of archives.
After this operation, 43.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce amd64 18.06.0~ce~3-0~ubuntu [40.1 MB]
Fetched 40.1 MB in 5s (6,935 kB/s)   
dpkg: docker-ce-cli: dependency problems, but removing anyway as you requested:
 docker-ce depends on docker-ce-cli.

(Reading database ... 136047 files and directories currently installed.)
Removing docker-ce-cli (5:18.09.0~3-0~ubuntu-xenial) ...
Processing triggers for man-db (2.7.5-1) ...
dpkg: warning: downgrading docker-ce from 5:18.09.0~3-0~ubuntu-xenial to 18.06.0~ce~3-0~ubuntu
(Reading database ... 135857 files and directories currently installed.)
Preparing to unpack .../docker-ce_18.06.0~ce~3-0~ubuntu_amd64.deb ...
Unpacking docker-ce (18.06.0~ce~3-0~ubuntu) over (5:18.09.0~3-0~ubuntu-xenial) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up docker-ce (18.06.0~ce~3-0~ubuntu) ...
A dependency job for docker.service failed. See '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: active (running) since Sat 2018-12-01 22:20:08 CST; 5min ago
     Docs: https://docs.docker.com
 Main PID: 32613 (dockerd)
   CGroup: /system.slice/docker.service
           └─32613 /usr/bin/dockerd -H unix://

Dec 01 22:20:07 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:07.671708387+08:00" level=warning msg="Your kernel does not support...runtime"
Dec 01 22:20:07 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:07.672189795+08:00" level=info msg="Loading containers: start."
Dec 01 22:20:08 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:08.055751832+08:00" level=info msg="Default bridge (docker0) is ass...address"
Dec 01 22:20:08 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:08.100131634+08:00" level=info msg="Loading containers: done."
Dec 01 22:20:08 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:08.120069347+08:00" level=info msg="Docker daemon" commit=4d60db4 g...=18.09.0
Dec 01 22:20:08 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:08.120538965+08:00" level=info msg="Daemon has completed initialization"
Dec 01 22:20:08 iZm5egn5zptnov4j3oxh4fZ systemd[1]: Started Docker Application Container Engine.
Dec 01 22:20:08 iZm5egn5zptnov4j3oxh4fZ dockerd[32613]: time="2018-12-01T22:20:08.147198090+08:00" level=info msg="API listen on /var/run/docker.sock"
Dec 01 22:25:16 iZm5egn5zptnov4j3oxh4fZ systemd[1]: Dependency failed for Docker Application Container Engine.
Dec 01 22:25:16 iZm5egn5zptnov4j3oxh4fZ systemd[1]: docker.service: Job docker.service/start failed with result 'dependency'.
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 systemd (229-4ubuntu21.2) ...
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)

解决方法

安装相应的依赖项解决该问题。

sudo apt-get install docker-ce-cli

详细信息如下:

Z:~/software$ sudo apt-get install docker-ce-cli
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  docker-ce
The following NEW packages will be installed:
  docker-ce-cli
The following packages will be upgraded:
  docker-ce
1 upgraded, 1 newly installed, 0 to remove and 163 not upgraded.
1 not fully installed or removed.
Need to get 0 B/30.4 MB of archives.
After this operation, 43.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 136066 files and directories currently installed.)
Preparing to unpack .../docker-ce_5%3a18.09.0~3-0~ubuntu-xenial_amd64.deb ...
Unpacking docker-ce (5:18.09.0~3-0~ubuntu-xenial) over (18.06.0~ce~3-0~ubuntu) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../docker-ce-cli_5%3a18.09.0~3-0~ubuntu-xenial_amd64.deb ...
Unpacking docker-ce-cli (5:18.09.0~3-0~ubuntu-xenial) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up docker-ce-cli (5:18.09.0~3-0~ubuntu-xenial) ...
Setting up docker-ce (5:18.09.0~3-0~ubuntu-xenial) ...
update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode
wohu@iZm5egn5zptnov4j3oxh4fZ:~/software$ systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-12-01 22:31:06 CST; 46s ago
     Docs: https://docs.docker.com
 Main PID: 3001 (dockerd)
    Tasks: 8
   Memory: 28.9M
      CPU: 149ms
   CGroup: /system.slice/docker.service
           └─3001 /usr/bin/dockerd -H unix://

你可能感兴趣的:(Docker)