用yum方式安装docker遇到错误的以下问题:
Docker 无法启动
[root@localhost 桌面]# yum update
[root@localhost 桌面]# yum install docker
[root@localhost 桌面]# service docker start 启动docker之后报错如下
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@localhost 桌面]# service docker restart
Redirecting to /bin/systemctl restart docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@localhost 桌面]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 二 2018-12-04 23:37:34 CST; 1min 24s ago
Docs: http://docs.docker.com
Process: 21320 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 21320 (code=exited, status=1/FAILURE)
12月 04 23:37:34 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
12月 04 23:37:34 localhost.localdomain dockerd-current[21320]: unable to configure the Docker daemon with file /etc/docker/daem...rlay)
12月 04 23:37:34 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
12月 04 23:37:34 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
12月 04 23:37:34 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
12月 04 23:37:34 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
解决方案:我的解决方案是删除用yum方式安装的docker之后换成以下这种
[root@localhost 桌面]# yum remove docker
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker.x86_64.2.1.13.1-84.git07f3374.el7.centos 将被 删除
--> 解决依赖关系完成
依赖关系解决
========================================================================================================================================
Package 架构 版本 源 大小
========================================================================================================================================
正在删除:
docker x86_64 2:1.13.1-84.git07f3374.el7.centos @extras 56 M
事务概要
========================================================================================================================================
移除 1 软件包
安装大小:56 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : 2:docker-1.13.1-84.git07f3374.el7.centos.x86_64 1/1
警告:文件 /var/lib/docker: 移除失败: 没有那个文件或目录
警告:/etc/sysconfig/docker-storage 已另存为 /etc/sysconfig/docker-storage.rpmsave
警告:/etc/docker/daemon.json 已另存为 /etc/docker/daemon.json.rpmsave
验证中 : 2:docker-1.13.1-84.git07f3374.el7.centos.x86_64 1/1
删除:
docker.x86_64 2:1.13.1-84.git07f3374.el7.centos
完毕!
[root@localhost 桌面]# yum remove docker-selinux
已加载插件:fastestmirror, langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.74-1.el7 将被 删除
--> 正在处理依赖关系 container-selinux >= 2:2.51-1,它被软件包 2:docker-common-1.13.1-84.git07f3374.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 docker-common.x86_64.2.1.13.1-84.git07f3374.el7.centos 将被 删除
--> 正在处理依赖关系 docker-common,它被软件包 2:docker-client-1.13.1-84.git07f3374.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 docker-client.x86_64.2.1.13.1-84.git07f3374.el7.centos 将被 删除
--> 解决依赖关系完成
依赖关系解决
========================================================================================================================================
Package 架构 版本 源 大小
========================================================================================================================================
正在删除:
container-selinux noarch 2:2.74-1.el7 @extras 37 k
为依赖而移除:
docker-client x86_64 2:1.13.1-84.git07f3374.el7.centos @extras 12 M
docker-common x86_64 2:1.13.1-84.git07f3374.el7.centos @extras 4.4 k
事务概要
========================================================================================================================================
移除 1 软件包 (+2 依赖软件包)
安装大小:12 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : 2:docker-client-1.13.1-84.git07f3374.el7.centos.x86_64 1/3
正在删除 : 2:docker-common-1.13.1-84.git07f3374.el7.centos.x86_64 2/3
正在删除 : 2:container-selinux-2.74-1.el7.noarch 3/3
验证中 : 2:container-selinux-2.74-1.el7.noarch 1/3
验证中 : 2:docker-client-1.13.1-84.git07f3374.el7.centos.x86_64 2/3
验证中 : 2:docker-common-1.13.1-84.git07f3374.el7.centos.x86_64 3/3
删除:
container-selinux.noarch 2:2.74-1.el7
作为依赖被删除:
docker-client.x86_64 2:1.13.1-84.git07f3374.el7.centos docker-common.x86_64 2:1.13.1-84.git07f3374.el7.centos
完毕!
[root@localhost 桌面]# vi /etc/yum.repos.d/docker.repo
修改这个配置文件vi /etc/yum.repos.d/docker.repo在里面加以下配置信息:
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
之后:wq保存
之后运行如下命令
[root@localhost 桌面]# yum install docker-engine
已加载插件:fastestmirror, langpacks
dockerrepo | 2.9 kB 00:00:00
dockerrepo/7/primary_db | 34 kB 00:00:04
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-engine.x86_64.0.17.05.0.ce-1.el7.centos 将被 安装
--> 正在处理依赖关系 docker-engine-selinux >= 17.05.0.ce-1.el7.centos,它被软件包 docker-engine-17.05.0.ce-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 docker-engine-selinux.noarch.0.17.05.0.ce-1.el7.centos 将被 安装
--> 解决依赖关系完成
依赖关系解决
========================================================================================================================================
Package 架构 版本 源 大小
========================================================================================================================================
正在安装:
docker-engine x86_64 17.05.0.ce-1.el7.centos dockerrepo 19 M
为依赖而安装:
docker-engine-selinux noarch 17.05.0.ce-1.el7.centos dockerrepo 28 k
事务概要
========================================================================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:20 M
安装大小:70 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/dockerrepo/packages/docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 2c52609d: NOKEY
docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch.rpm 的公钥尚未安装
(1/2): docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch.rpm | 28 kB 00:00:03
(2/2): docker-engine-17.05.0.ce-1.el7.centos.x86_64.rpm | 19 MB 00:02:29
----------------------------------------------------------------------------------------------------------------------------------------
总计 134 kB/s | 20 MB 00:02:29
从 https://yum.dockerproject.org/gpg 检索密钥
导入 GPG key 0x2C52609D:
用户ID : "Docker Release Tool (releasedocker) <docker@docker.com>"
指纹 : 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
来自 : https://yum.dockerproject.org/gpg
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch 1/2
Re-declaration of type docker_t
Failed to create node
Bad type declaration at /etc/selinux/targeted/tmp/modules/400/docker/cil:1
/usr/sbin/semodule: Failed!
restorecon: lstat(/var/lib/docker) failed: No such file or directory
warning: %post(docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch) scriptlet failed, exit status 255
Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch
正在安装 : docker-engine-17.05.0.ce-1.el7.centos.x86_64 2/2
验证中 : docker-engine-17.05.0.ce-1.el7.centos.x86_64 1/2
验证中 : docker-engine-selinux-17.05.0.ce-1.el7.centos.noarch 2/2
已安装:
docker-engine.x86_64 0:17.05.0.ce-1.el7.centos
作为依赖被安装:
docker-engine-selinux.noarch 0:17.05.0.ce-1.el7.centos
完毕!
之后启动docker 问题就解决了
[root@localhost 桌面]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@localhost 桌面]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost 桌面]# docker version
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:06:25 2017
OS/Arch: linux/amd64
Server:
Version: 17.05.0-ce
API version: 1.29 (minimum version 1.12)
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:06:25 2017
OS/Arch: linux/amd64
Experimental: false