linux centos7安装docker
时间: 2024-11-18 12:14:46 浏览: 19
在 CentOS 7 系统上安装 Docker 需要几个步骤:
1. **更新包列表**:
```sh
sudo yum update -y
```
2. **添加 Docker GPG 公钥**:
```sh
curl -fsSL https://download.docker.com/linux/centos/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
3. **配置仓库**:
```sh
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/centos/$(uname -m) $(lsb_release -cs) stable" \
| sudo tee /etc/yum.repos.d/docker-ce.repo > /dev/null
```
4. **安装 Docker**:
```sh
sudo yum install docker-ce docker-ce-cli containerd.io -y
```
5. **启动并启用 Docker**:
```sh
sudo systemctl start docker
sudo systemctl enable docker
```
6. **验证安装**:
可以通过运行 `sudo docker run hello-world` 来测试 Docker 是否已成功安装。
阅读全文