确保yum包更新到最新
yum -y update
卸载旧版本(如果安装过旧版本的话)
sudo yum remove -y docker*
安装需要的软件包
yum install -y yum-utils
设置yum源,并更新 yum 的包索引
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
建立元数据缓存
yum makecache fast
安装Docker
yum install -y docker-ce
启动Docker
systemctl start docker
设置开机自动启动
systemctl enable docker
查看版本信息
docker version
## 配置docker镜像加速器
cd /etc/docker
vim daemon.json
将这段配置进去
{
"registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"]
}
重启daocker
systemctl restart docker
通过运行hello-world镜像来验证是否正确安装了Docker Engine-Community
docker pull hello-world
docker run hello-world
出现下面结果代表安装成功