解決docker在CentOs7中安裝好執行不了問題
用yum方式安裝docker遇到錯誤的以下問題:
Docker 無法啟動
[[email protected] 桌面]# yum update
[[email protected] 桌面]# yum install docker
[[email protected] 桌面]# 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.
[
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.
[[email protected] 桌面]# 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之後換成以下這種
[[email protected] 桌面]# 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
完畢!
[[email protected] 桌面]# 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
完畢!
[[email protected] 桌面]# 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儲存
之後執行如下命令
[[email protected] 桌面]# 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) <[email protected]>"
指紋 : 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 問題就解決了
[[email protected] 桌面]# service docker start
Redirecting to /bin/systemctl start docker.service
[[email protected] 桌面]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[[email protected] 桌面]# 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