官方地址安装

sudo dnf update
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install docker-ce --nobest

sudo systemctl start docker
sudo systemctl enable docker

阿里云镜像安装

#安装yum-utils
dnf install yum-utils -y

#添加docker仓库
dnf config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#安装最新版本的docker
#安装docker包括:docker Engine, containerd, and Docker Compose
dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

#配置docker-compose环境变量
#编辑当前用户环境变量配置文件 ~/.bashrc
nano ~/.bashrc
#向 ~/.bashrc追加export PATH="/usr/libexec/docker/cli-plugins:$PATH"
# docker更改为国内腾讯镜像源
cat /etc/docker/daemon.json

cat <<EOL >/etc/docker/daemon.json
{
    "registry-mirrors": [
        "https://mirror.ccs.tencentyun.com",
        "https://docker.mirrors.ustc.edu.cn" ],
    "log-driver":"json-file",
    "log-opts": {"max-size":"5m", "max-file":"5"}
}
EOL
systemctl daemon-reload
systemctl restart docker
systemctl enable docker

docker info