1. 安装 yum工具
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2 --skip-broken
2. 更新本地镜像源
yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
// 上面源的地址换成最新的
sed -i 's/download.docker.com/mirrors.tuna.tsinghua.edu.cn\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
3. 检查源配置
vim /etc/yum.repos.d/docker-ce.repo
4. 安装
// 建立缓存,可跳过
yum makecache fast
// 安装
yum install -y docker-ce
5. 启动
# 启动
systemctl start docker
# 查看状态
systemctl status docker
# 停止
systemctl stop docker
# 重启
systemctl restart docker
6. 配置 docker 镜像
sudo cp -n /lib/systemd/system/docker.service /etc/systemd/system/docker.service
sudo sed -i "s|ExecStart=/usr/bin/docker daemon|ExecStart=/usr/bin/docker daemon --registry-mirror=<your accelerate address>|g" /etc/systemd/system/docker.service
sudo sed -i "s|ExecStart=/usr/bin/dockerd|ExecStart=/usr/bin/dockerd --registry-mirror=<your accelerate address>|g" /etc/systemd/system/docker.service
# 重启
sudo systemctl daemon-reload
sudo service docker restart
7. 卸载
yum remove docker-ce
rem-rf /var/lib/docker