Docker在Centos 7上的部署
方法1---開啟centos 7上自帶的 extras YUM源,然后 yum install docker來安裝
安裝前必須保證 Linux Kernel 要 3.10+, 用 uname -r 查這個參數
[root@Franklin13 yum.repos.d]# cat CentOS-Base.repo |grep -a2 extras
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
enabled=1
gpgcheck=1
但 extras源里的 docker的版本很低,故采用如下方法:
方法2 --- 通過下載清華大學上的開源 docker-ce YUM源來安裝
https://download.docker.com ---> 替換成 https://mirrors.tuna.tsinghua.edu.cn/docker-ce
然后出現如下報錯, 經查是清華大學的 URL地址寫錯了,docker-ce后少打了 /。之后修復成功
yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true
failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://mirrors.tuna.tsinghua.edu.cn/docker-celinux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
[root@Franklin13 ~]#
---整理相關報錯詳情
--> Finished Dependency Resolution
Error: Package: 2:container-selinux-2.107-3.el7.noarch (extras)
Requires: selinux-policy >= 3.13.1-216.el7
Installed: selinux-policy-3.13.1-166.el7.noarch (@anaconda)
selinux-policy = 3.13.1-166.el7
Error: Package: 2:container-selinux-2.107-3.el7.noarch (extras)
Requires: selinux-policy-targeted >= 3.13.1-216.el7
Installed: selinux-policy-targeted-3.13.1-166.el7.noarch (@anaconda)
selinux-policy-targeted = 3.13.1-166.el7
Error: Package: 2:container-selinux-2.107-3.el7.noarch (extras)
Requires: selinux-policy-base >= 3.13.1-216.el7
Installed: selinux-policy-targeted-3.13.1-166.el7.noarch (@anaconda)
selinux-policy-base = 3.13.1-166.el7
Available: selinux-policy-minimum-3.13.1-166.el7.noarch (c7-media)
selinux-policy-base = 3.13.1-166.el7
Available: selinux-policy-mls-3.13.1-166.el7.noarch (c7-media)
selinux-policy-base = 3.13.1-166.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@Franklin13 ~]#
[root@Franklin13 ~]# yum update selinux-policy
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* extras: ftp.sjtu.edu.cn
No packages marked for update
[root@Franklin13 ~]#
----------------------故不得不求救於馬雲的阿里雲鏡像, 看如下 --------------------------
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@Franklin13 yum.repos.d]# yum install docker-ce (發現只有阿里雲的 docker-ce源可以自動解決軟件的依賴包問題 )
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
[root@Franklin13 yum.repos.d]# systemctl start docker.service
[root@Franklin13 yum.repos.d]# docker version
[root@Franklin13 yum.repos.d]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@Franklin13 yum.repos.d]#
[root@Franklin13 yum.repos.d]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.4
Storage Driver: overlay2