1 yum命令安装(不推荐)
yum install docker
2 脚本自动安装最新版本(推荐)
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
curl -sSL https://get.daocloud.io/docker | sh
3 手动安装制定版本(推荐)
3.1 安装基础环境和Docker源:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum update -y
3.2 查看支持版本列表:
sudo yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 3:23.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.23-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.22-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.21-3.el7 @docker-ce-stable
docker-ce.x86_64 3:20.10.20-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.19-3.el7 docker-ce-stable
...
...
...
3.3 安装指定版本Docker
sudo yum install -y docker-ce-20.10.21 docker-ce-cli-20.10.21 containerd.io
4 启动Docker服务
systemctl enable docker
systemctl start docker
systemctl daemon-reload
systemctl restart docker
systemctl stop docker
5 Docker用户组管理
sudo groupadd docker
sudo usermod -aG docker <username>
6 安装Docker-compose
wget -O docker-compose https://github.com/docker/compose/releases/download/v2.10.1/docker-compose-linux-x86_64
wget -O docker-compose https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose
sudo mv docker-compose /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version