ubuntu安装docker
时间: 2023-07-07 18:47:01 浏览: 140
Ubuntu 安装 Docker
你可以按照以下步骤在 Ubuntu 上安装 Docker:
1. 更新软件包索引:
```
sudo apt update
```
2. 安装依赖包,以允许 apt 通过 HTTPS 使用存储库:
```
sudo apt 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. 设置稳定存储库:
```
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```
5. 更新软件包索引:
```
sudo apt update
```
6. 安装最新版本的 Docker:
```
sudo apt install docker-ce docker-ce-cli containerd.io
```
7. 确认 Docker 是否已正确安装并正在运行:
```
sudo systemctl status docker
```
如果 Docker 正在运行,则该命令将输出类似于以下内容的信息:
```
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-23 16:09:03 UTC; 1 weeks 2 days ago
Docs: https://docs.docker.com
Main PID: 10330 (dockerd)
Tasks: 13
Memory: 45.6M
CGroup: /system.slice/docker.service
├─10330 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─10364 docker-containerd --config /var/run/docker/containerd/containerd.toml
├─13386 docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/0f9c3f3d3b5926ba0a7c8997f3bcb7fb56ef3f3e8b6d5cf1cc0be3adfe63d6d8 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
├─13422 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.17.0.3 -container-port 80
├─13439 docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/2fccbfcde2c4d2c34580c4277557a6e4f0d8d1f634bfc1f56b0cb3a6e93e85b7 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
├─13856 docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/6be7d5235e8fdccf227f41d2c4c4f1c1a7e762a5d8b16dd4ee1f5af2f7e28c5c -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
├─13889 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 443 -container-ip 172.17.0.4 -container-port 443
└─13906 docker-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/4a8f4f9f35a1c7f88b8f9f27f9f1a2f7e4b15b9d6f1c5e840c6f6a3c9c4f7d5c -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc
```
现在你已经成功地在 Ubuntu 上安装了 Docker。
阅读全文