参考:官网地址
1.卸载干净旧版本
$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
2.安装所需的软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
3.设置稳定的存储库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4.查看可安装版本
yum list docker-ce --showduplicates | sort -r
5.安装
yum -y install docker-ce-18.03.1.ce-1.el7.centos systemctl start docker(启动docker) systemctl enable docker(设为开机启动) docker run hello-world
6.阿里云镜像加速
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-‘EOF‘ { "registry-mirrors": ["https://q5peftms.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
原文:https://www.cnblogs.com/shifu204/p/12617637.html