Docker在Centos 7上的部署

方法1---开启centos 7上自带的 extras YUM源,然后 yum install docker来安装

安装前必须保证 Linux Kernel 要 3.10+, 用 uname -r 查这个参数

Docker在Centos 7上的部署-LMLPHP

[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

Docker在Centos 7上的部署-LMLPHP

但 extras源里的 docker的版本很低,故采用如下方法:

方法2 --- 通过下载清华大学上的开源 docker-ce YUM源来安装

Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

https://download.docker.com ---> 替换成  https://mirrors.tuna.tsinghua.edu.cn/docker-ce

Docker在Centos 7上的部署-LMLPHP

然后出现如下报错, 经查是清华大学的 URL地址写错了,docker-ce后少打了 /。之后修复成功

Docker在Centos 7上的部署-LMLPHP

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 ~]#
Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

---整理相关报错详情

--> 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

Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

[root@Franklin13 yum.repos.d]# yum install docker-ce (发现只有阿里云的 docker-ce源可以自动解决软件的依赖包问题 )

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile

Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

Docker在Centos 7上的部署-LMLPHP

[root@Franklin13 yum.repos.d]# systemctl start docker.service
[root@Franklin13 yum.repos.d]# docker version

Docker在Centos 7上的部署-LMLPHP

[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

05-19 12:50