CentOS7安装Docker及设置仓库源

yum方式安装Docker

1.查看Centos版本命令

[root@suzhongde suzhongde]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

这里CentOS Linux release 7.9.2009 (Core)的版本必须大于3.0

2.需要确保当前安装的CentOS系统可以上网

[root@suzhongde suzhongde]# ping www.baidu.com
PING www.a.shifen.com (163.177.151.109) 56(84) bytes of data.
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=1 ttl=54 time=9.02 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=2 ttl=54 time=9.83 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=3 ttl=54 time=9.60 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=4 ttl=54 time=9.77 ms

3.使用yum安装gcc相关依赖

# 在终端依次输入以下命令
yum -y install gcc
yum -y install gcc-c++

4.如果以前安装过docker 请卸载它们以及相关的依赖项

# 在终端输入以下命令
yum remove docker \
            docker-client \
            docker-client-latest \
            docker-common \
            docker-latest \
            docker-latest-logrotate \
            docker-logrotate \
            docker-engine

5.安装yum-utils

[root@suzhongde suzhongde]# yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do

6.设置稳定的存储库

[root@suzhongde suzhongde]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

7.配置yum源之后更新软件包的索引

[root@suzhongde suzhongde]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
base                                                                                                                                                                                                                      | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                                                                                                          | 3.5 kB  00:00:00     
extras                                                                                                                                                                                                                    | 2.9 kB  00:00:00     
updates                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
(1/2): docker-ce-stable/7/x86_64/primary_db                                                                                                                                                                               |  73 kB  00:00:05     
docker-ce-stable/7/x86_64/upda FAILED                                          
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080-updateinfo.xml.gz: [Errno 14] curl#51 - "Unable to communicate securely with peer: requested domain name does not match the server's certificate."
Trying other mirror.
Metadata Cache Created

8.安装 Docker Engine

[root@suzhongde suzhongde]# yum -y install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.5.10-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.5.10-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.13-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.13-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.13-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.13-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package docker-ce-rootless-extras.x86_64 0:20.10.13-3.el7 will be installed
--> Processing De
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值