确定你是Centos7版本以上
cat /etc/redhat-release
安装gcc
yum -y install gcc
yum -y install gcc-c++
卸载旧的版本
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装需要软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
设置stable镜像仓库(这里采用阿里,连接国外docker.com,会出现ERROR12,ERROR14问题)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新yum软件包索引
yum makecache fast
安装docker-ce
yum -y install docker-ce
启动docker
systemctl start docker
测试
docker version #看版本
docker run hello-world
yum镜像加速配置
mkdir -p /etc/docker
vim /etc/docker/daemon.json
#daemon.json写入
{
"registry-mirrors":["https://{自己的字符码}.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker
卸载
systemctl stop docker
yum -y remove docker-ce
rm -rf /var/lib/docker
原文:https://www.cnblogs.com/xujunkai/p/13031209.html