1.卸载旧版本
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
2.安装需要的软件包
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
//设置yum源
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
3.安装Docker CE
$ sudo yum install docker-ce
4.启动并加入开机启动
$ sudo systemctl start docker
$ sudo systemctl enable docker
5.验证是否安装成功
//一般包含client和server两部分代表安装成功
$ docker version
6.官方镜像加速
// /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}