Centos 安装docker

卸载旧版本

1
2
3
4
5
6
7
8
9
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

安装

设置储存库

1
2
3
4
5
sudo yum install -y yum-utils

sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

安装docker引擎

1
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

列出版本号

1
yum list docker-ce --showduplicates | sort -r
1
2
3
4
5
6
7
8
9
10
[root@VM-4-11-centos /]#  yum list docker-ce --showduplicates | sort -r
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
Installed Packages
docker-ce.x86_64 3:24.0.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.4-1.el7 @docker-ce-stable
docker-ce.x86_64 3:24.0.3-1.el7 docker-ce-stable
#<VERSION_STRING> ---版本号
#docker-ce.x86_64 3:<VERSION_STRING>-1.el7 docker-ce-stable

安装指定版本号的软件

1
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-compose-plugin

eg:安装

1
sudo yum install docker-ce-24.0.4 docker-ce-cli-24.0.4 containerd.io docker-compose-plugin

启动docker

1
sudo systemctl start docker