ubuntu docker 安装代码
时间: 2024-06-09 22:04:08 浏览: 133
在Ubuntu上安装Docker,你可以按照以下步骤进行:
1. 更新包列表并安装必要的依赖项:
```bash
sudo apt-https ca-certificates curl gnupg lsb-release
```
2. 添加Docker GPG公钥:
```bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
3. 将Docker仓库添加到apt源:
```bash
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
```
4. 更新apt源并安装Docker:
```bash
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
5. 启动和启用docker服务:
```bash
sudo systemctl start docker
sudo systemctl enable docker
```
6. 验证Docker是否安装成功:
```bash
sudo docker run hello-world
```
阅读全文