更新yum包
yum -y update
卸载旧版本
yum remove docker-ce docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装docker
yum install -y yum-utils device-mapper-persistent-data lvm2
设置yum源
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装最新版本的 Docker Engine-Community 和 containerd
yum -y install docker-ce docker-ce-cli containerd.io
查看安装版本
yum list docker-ce --showduplicates | sort -r
安装指定版本
yum -y install docker-ce-27.1.2 docker-ce-cli-27.1.2 containerd.io
查看版本
docker -v
docer version
启动docker并设置开机自启
systemctl start docker
systemctl enable docker
systemctl stop docker
systemctl restart docker
systemctl status docker