在 CentOS 7 上安装 Docker CE 和 Docker Compose
# 安装必要的依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
# 添加 Docker CE 仓库
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 更新缓存
yum makecache fast
# 安装 Docker CE
yum install docker-ce docker-ce-cli containerd.io
# 启动 Docker 并设置开机自启
systemctl start docker
systemctl enable docker
# 检查 Docker 状态
systemctl status docker
# (可选)将当前用户添加到 docker 组
sudo usermod -aG docker $USER
newgrp docker
# 下载并安装 Docker Compose
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 赋予可执行权限
chmod +x /usr/local/bin/docker-compose
# 验证安装
docker -v
docker-compose -v