1-安装Docker所需的包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
2-安装stable仓库
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
3-[可选]启用edge和test仓库
# 启用edge仓库
sudo yum-config-manager --enable docker-ce-edge
# 启用test仓库
sudo yum-config-manager --enable docker-ce-test
# 禁用edge仓库
sudo yum-config-manager --disable docker-ce-edge
# 禁用test仓库
sudo yum-config-manager --disable docker-ce-test
4-安装Docker CE
# 更新yum的包索引
sudo yum makecache fast
# 安装最新版本Docker CE
sudo yum install docker-ce
5-启动Docker
sudo systemctl start docker
6-验证安装是否正确
sudo docker run hello-world
7-升级Docker CE
sudo yum makecache fast
8-配置镜像加速器
地址由阿里云产生,可去阿里云申请
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://znbtai33.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
9-开机自启
sudo systemctl enable docker
10-查看docker版本
docker version