docker ubuntu 安装
时间: 2024-08-12 11:01:57 浏览: 151
Ubuntu离线安装docker
Docker是一个开源的应用容器引擎,它允许你在一台主机上运行多个独立的、隔离的Linux环境,每个这样的环境被称为一个“镜像”。要在Ubuntu系统中安装Docker,你可以按照以下步骤操作:
1. **更新包列表**:
```sh
sudo apt update
```
2. **添加官方Docker仓库**:
```sh
sudo add-apt-repository ppa:docker-compose/stable
```
3. **安装依赖**:
```sh
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```
4. **添加Docker GPG key**:
```sh
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
5. **启用并安装Docker**:
```sh
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
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
6. **启动和启用服务**:
```sh
sudo systemctl start docker
sudo systemctl enable docker
```
7. **验证安装**:
运行 `sudo docker run hello-world` 来确认Docker是否安装成功。
阅读全文