ubuntu20.04安装docker-ce教程
时间: 2024-10-20 18:16:46 浏览: 73
Ubuntu20.04-nvidia-nvidia-docker离线资源
在Ubuntu 20.04上安装Docker CE(Community Edition),你可以按照以下步骤操作:
1. **更新包列表并添加Docker仓库**:
```
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```
2. **确认并安装**:
```
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
安装过程中可能会询问是否设置自动运行容器,输入`y`表示同意。
3. **启动并启用Docker**:
```
sudo systemctl start docker
sudo systemctl enable docker
```
4. **验证安装**:
运行以下命令检查Docker是否安装成功,并查看运行状态:
```
sudo docker run hello-world
```
5. **登录Docker Hub** (如果需要):
```bash
sudo docker login
```
阅读全文