1.如果机器原来有Docker,可以先卸载原来的docker
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
2.安装一些系统工具,将来能用得到
yum -y install -y yum-utils device-mapper-persistent-data lvm2
3.导入docker的仓库信息
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4 开始docker安装,如果是按版本安装就按下面的例子安装
yum install docker-ce-20.10.5 docker-ce-cli-20.10.5 docker-ce-rootless-extras-20.10.5 -y
如果安装最新版本就按下面的安装
yum install docker-ce -y
安装完成后,测试docker是否安装完毕。
启动docker
systemctl start docker
运行hellowrod docker
docker run hello-world
5.由于国外的仓库很多较慢,所以有时候我们一般启用国内的仓库地址
我这里整理的国内仓库地址有这些
Docker中国区官方镜像581bc19ee01e
https://registry.docker-cn.com
网易
http://hub-mirror.c.163.com
ustc
https://docker.mirrors.ustc.edu.cn
中国科技大学
https://docker.mirrors.ustc.edu.cn
阿里云容器 服务
https://cr.console.aliyun.com/
腾讯
https://mirror.ccs.tencentyun.com/
vi /etc/docker/daemon.json
加入如下内容
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
}
加入后,重启docker,并且验证仓库是否加入成功
systemctl daemon-reload
systemctl restart docker.service
docker info|grep Mirrors -A 1