centos7服务器安装docker
时间: 2024-09-30 19:11:43 浏览: 33
在 CentOS 7 服务器上安装 Docker,您需要遵循以下步骤:
1. **检查系统更新**:
```
sudo yum update -y
```
2. **添加 Docker GPG 公钥**:
```
curl -fsSL https://download.docker.com/linux/centos/docker-ce.gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
3. **添加 Docker APT 仓库**(适用于 Red Hat 家族):
```
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/centos/$(uname -m) docker-ce stable" | sudo tee /etc/yum.repos.d/docker.repo > /dev/null
```
4. **安装 Docker**:
```
sudo yum install docker-ce docker-ce-cli containerd.io -y
```
5. **启动并启用 Docker**:
```
sudo systemctl start docker
sudo systemctl enable docker
```
6. **验证 Docker 是否安装成功**:
```
sudo docker run hello-world
```
阅读全文