Centos7系统 docker指定版本安装【官方文档步骤】
官方文档地址:https://docs.docker.com/engine/install/centos/
# 1.安装yum工具及设置docker-ce镜像库
sudo yum install -y yum-utils# 国外的镜像下载太慢了改成阿里云镜像库
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo# 2.阿里云镜像库
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# 3.查询docker可用稳定版本
yum list docker-ce --showduplicates | sort -r[root@localhost ~]# 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.6-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.6-1.el7 @docker-ce-stable
docker-ce.x86_64 3:24.0.5-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
docker-ce.x86_64 3:24.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.6-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.5-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.4-1.el7 docker-ce-stable # 4.安装指定版本<24.0.6>版本
yum install docker-ce-24.0.6 -y# 5.添加开机启动docker服务及运行启动docker服务
systemctl enable docker
systemctl start docker
Ubuntu20.04系统 docker指定版本安装
# 1.移除旧版docker
sudo apt-get remove docker docker-engine docker.io containerd runc# 2.更新包索引
sudo apt-get update# 3.安装依赖库
sudo apt-get install\apt-transport-https \ca-certificates \curl \gnupg-agent \software-properties-common# 4.添加 Docker 的官方 GPG 密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -# 5.设置稳定版仓库
sudo add-apt-repository \"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu/ \$(lsb_release -cs) \stable"# 6.查看可用版本
sudo apt-cache madison docker-cedev@localhost:~$ sudo apt-cache madison docker-cedocker-ce | 5:24.0.7-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.6-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.5-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.4-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.3-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.2-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.1-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:24.0.0-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.6-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.5-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.4-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.3-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.2-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.1-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:23.0.0-1~ubuntu.20.04~focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.24~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.23~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.22~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.21~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.20~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.19~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packagesdocker-ce | 5:20.10.18~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages# 7.安装docker 20.10版本
sudo apt-get install docker-ce=5:20.10.22~3-0~ubuntu-focal docker-ce-cli=5:20.10.22~3-0~ubuntu-focal containerd.io# 8.配置普通用户使用docker免去sudosudo usermod -aG docker dev
docker-compose安装
#!/bin/bashsudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-composechmod u+x /usr/local/bin/docker-composedocker-compose --version