linux 安装 docker
时间: 2023-10-13 20:24:53 浏览: 16
安装 Docker 在 Linux 上有多种方法,以下是其中一种常见的方法:
1. 更新系统软件包列表:
```
sudo apt-get update
```
2. 安装 Docker 的依赖包:
```
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```
3. 添加 Docker GPG 密钥:
```
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```
4. 添加 Docker 的 APT 仓库:
```
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```
5. 再次更新系统软件包列表:
```
sudo apt-get update
```
6. 安装 Docker:
```
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
7. 验证 Docker 安装成功:
```
sudo docker run hello-world
```
如果一切正常,你应该能看到类似下面的输出:
```
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
```