Linux安裝docker過程中出現版本依賴問題該如何解決


安裝docker的官方步驟,參考docker的官方網站:https://docs.docker.com/engine/install/centos/。

為了保證docker的安裝過程順利,首先要注意部署docker的環境,小編的環境Red Hat Enterprise Linux Server release 7.5,內核:3.10.0-862.el7.x86_64,安裝docker對系統環境要求:centos7.5 64位 內核版本高於3.10,centos6.5 64位 內核版本高於2.6.32,因為內核包含了運行Docker的一些特定修改。

這里簡單描述安裝步驟,詳細步驟請參考官方網站:

  • 卸載自帶的包:
1 yum remove docker \
2                   docker-client \
3                   docker-client-latest \
4                   docker-common \
5                   docker-latest \
6                   docker-latest-logrotate \
7                   docker-logrotate \
8                   docker-engine
  • 安裝依賴包:
1 yum install -y yum-utils
  •  設置鏡像:
1 yum-config-manager \
2     --add-repo \
3     https://download.docker.com/linux/centos/docker-ce.repo
  • 執行安裝命令,安裝docker:
1 yum install docker-ce docker-ce-cli containerd.io
  • 啟動docker:
1 systemctl start docker
  • 輸入docker version來測試docker是否成功安裝:

 如果看到上述的client和server,說明兩者均起成功,如果docker只啟動了client,通過輸入service docker start或者systemctl restart docker來開啟server,之后再次輸入docker version來驗證;

 

完成之后可以用docker測試helloworld,步驟如下:

  • 輸入docker pull hello-world來拉取hello-world鏡像

 輸入docker run hello-world運行,出現下圖所示內容,說明hello-world運行成功:

 

 

小編在安裝的過程中出現版本依賴問題,研究了好久才終於徹底解決。

下面是執行安裝命令的時候出現的問題:

 1 [root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io  2 Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager  3 This system is not registered with an entitlement server. You can use subscription-manager to register.  4 Resolving Dependencies  5 --> Running transaction check  6 ---> Package containerd.io.x86_64 0:1.4.6-3.1.el7 will be installed  7 --> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.6-3.1.el7.x86_64  8 ---> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed  9 --> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.7-3.el7.x86_64 10 --> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.7-3.el7.x86_64 11 ---> Package docker-ce-cli.x86_64 1:20.10.7-3.el7 will be installed 12 --> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.7-3.el7.x86_64 13 --> Running transaction check 14 ---> Package containerd.io.x86_64 0:1.4.6-3.1.el7 will be installed 15 --> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.6-3.1.el7.x86_64 16 ---> Package docker-ce.x86_64 3:20.10.7-3.el7 will be installed 17 --> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.7-3.el7.x86_64 18 ---> Package docker-ce-rootless-extras.x86_64 0:20.10.7-3.el7 will be installed 19 --> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 20 --> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 21 ---> Package docker-scan-plugin.x86_64 0:0.8.0-3.el7 will be installed 22 --> Finished Dependency Resolution 23 Error: Package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 (docker-ce-stable) 24            Requires: fuse-overlayfs >= 0.7
25 Error: Package: docker-ce-rootless-extras-20.10.7-3.el7.x86_64 (docker-ce-stable) 26            Requires: slirp4netns >= 0.4
27 Error: Package: 3:docker-ce-20.10.7-3.el7.x86_64 (docker-ce-stable) 28            Requires: container-selinux >= 2:2.74
29            Installed: 2:container-selinux-2.68-1.el7.noarch (@extras) 30                container-selinux = 2:2.68-1.el7 31            Available: 2:container-selinux-2.42-1.gitad8f0f7.el7.noarch (extras) 32                container-selinux = 2:2.42-1.gitad8f0f7.el7 33            Available: 2:container-selinux-2.55-1.el7.noarch (extras) 34                container-selinux = 2:2.55-1.el7 35            Available: 2:container-selinux-2.66-1.el7.noarch (extras) 36                container-selinux = 2:2.66-1.el7 37 Error: Package: containerd.io-1.4.6-3.1.el7.x86_64 (docker-ce-stable) 38            Requires: container-selinux >= 2:2.74
39            Installed: 2:container-selinux-2.68-1.el7.noarch (@extras) 40                container-selinux = 2:2.68-1.el7 41            Available: 2:container-selinux-2.42-1.gitad8f0f7.el7.noarch (extras) 42                container-selinux = 2:2.42-1.gitad8f0f7.el7 43            Available: 2:container-selinux-2.55-1.el7.noarch (extras) 44                container-selinux = 2:2.55-1.el7 45            Available: 2:container-selinux-2.66-1.el7.noarch (extras) 46                container-selinux = 2:2.66-1.el7 47  You could try using --skip-broken to work around the problem 48  You could try running: rpm -Va --nofiles --nodigest

即便是重新安裝 yum reinstall container-selinux ,還是會出現上面的那種提示,其實真正的原因是所配置的yum倉庫的軟件包不是最新的,所以解決辦法就是更換/etc/yum.repos.d/CentOS7-Base-163.repo。小編這里提供下面兩種:

1、中科大(參考地址:http://mirrors.ustc.edu.cn/help/centos.html#)
 1 # CentOS-Base.repo  2 #  3 # The mirror system uses the connecting IP address of the client and the  4 # update status of each mirror to pick mirrors that are updated to and  5 # geographically close to the client.  You should use this for CentOS updates  6 # unless you are manually picking other mirrors.  7 #  8 # If the mirrorlist= does not work for you, as a fall back you can try the  9 # remarked out baseurl= line instead. 10 # 11 # 12 [base] 13 name=CentOS-$releasever - Base 14 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
15 baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
16 gpgcheck=1
17 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
18 #released updates 19 [updates] 20 name=CentOS-$releasever - Updates 21 # mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
22 baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
23 gpgcheck=1
24 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
25 #additional packages that may be useful 26 [extras] 27 name=CentOS-$releasever - Extras 28 # mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
29 baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
30 gpgcheck=1
31 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
32 #additional packages that extend functionality of existing packages 33 [centosplus] 34 name=CentOS-$releasever - Plus 35 # mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
36 baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
37 gpgcheck=1
38 enabled=0
39 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
2、清華源
 1 # CentOS-Base.repo  2 #  3 # The mirror system uses the connecting IP address of the client and the  4 # update status of each mirror to pick mirrors that are updated to and  5 # geographically close to the client.  You should use this for CentOS updates  6 # unless you are manually picking other mirrors.  7 #  8 # If the mirrorlist= does not work for you, as a fall back you can try the  9 # remarked out baseurl= line instead. 10 # 11 # 12 [base] 13 name=CentOS-$releasever - Base 14 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
15 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
16 gpgcheck=1
17 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
18 #released updates 19 [updates] 20 name=CentOS-$releasever - Updates 21 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
22 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
23 gpgcheck=1
24 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
25 #additional packages that may be useful 26 [extras] 27 name=CentOS-$releasever - Extras 28 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
29 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
30 gpgcheck=1
31 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
32 #additional packages that extend functionality of existing packages 33 [centosplus] 34 name=CentOS-$releasever - Plus 35 baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
36 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
37 gpgcheck=1
38 enabled=0
39 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
修改完成后更新yum源:
1 yum clean all
2 rm -rf  /var/cache/yum/
3 yum makecache

這時候,再次執行安裝docker的命令,終於安裝成功了!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM