1. 安装所需程序包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  1. 设置yum源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo #国外官方的
或
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #阿里云的
  1. 安装最新稳定版Docker CE
sudo yum install docker-ce
  1. 配置镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
      "https://docker.mirrors.ustc.edu.cn",
      "https://registry.docker-cn.com"
   ],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
    "max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
  1. 将当前登录用户加入docker用户组
sudo gpasswd -a $USER docker
newgrp docker  #更新用户组
  1. 启动 docker 并将其加入开机启动
sudo systemctl enable docker
sudo systemctl start docker
  1. 查看 docker 信息
docker version