安装docker
安装脚本
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
# 下载docker-compose
curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o /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
docker compose version
Docker Compose version v2.17.2
安装依赖包
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
鉴于国内网络问题,强烈建议使用国内源
sudo yum-config-manager \
--add-repo \
https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
$ sudo sed -i 's/download.docker.com/mirrors.ustc.edu.cn\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
安装 Docker CE
$ sudo yum makecache fast
$ sudo yum install docker-ce
启动 Docker CE
$ sudo systemctl enable docker
$ sudo systemctl start docker
测试 Docker 是否安装正确
$ docker run hello-world