ubuntu 安装docker环境
时间: 2024-06-23 11:00:22 浏览: 219
ubuntu系统脚本一件安装docker
Ubuntu安装Docker环境的步骤如下:
1. 更新系统和添加Docker GPG密钥:
```sh
sudo apt update && sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
2. 添加Docker的apt repository到系统:
```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
```
3. 更新软件包列表并安装Docker:
```sh
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
4. 启动和启用Docker服务:
```sh
sudo systemctl start docker
sudo systemctl enable docker
```
5. 验证Docker是否安装成功:
```sh
sudo docker run hello-world
```
阅读全文