1.安装yum套件管理工具
yum install -y yum-utils
2.设置稳定的仓库
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
感觉慢的话也可以选择国内的镜像源
清华镜像源
yum-config-manager \
--add-repo \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
阿里云镜像(推荐)
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安装Docker(社区版)
默认安装最新版本
yum install docker-ce docker-ce-cli containerd.io
安装其他版本
yum list docker-ce --showduplicates | sort -r
4.启动docker
systemctl start docker
运行docker hello-world
docker run hello-world
5.解决docker下载镜像慢的问题
注册阿里云
https://cr.console.aliyun.com/
注册完成后点击镜像加速器
在linux终端输入
vim /etc/docker/daemon.json
然后将下面内容写进去
{
"registry-mirrors": ["根据自己情况而定"]
}
重新加载文件
systemctl daemon-reload
重启docker
systemctl restart docker
查看docker信息
docker info
看看镜像是否配置成功