ubuntu安装Docker和Docker Compose
时间: 2024-01-27 13:06:03 浏览: 256
ubuntu安装docker
以下是在Ubuntu上安装Docker和Docker Compose的步骤:
1.卸载旧版本Docker(如果有的话)
```shell
sudo apt-get remove docker docker-engine docker.io containerd runc
```
2.更新apt包索引并安装依赖包
```shell
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
```
3.添加Docker官方的GPG密钥
```shell
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```
4.添加Docker官方的APT仓库
```shell
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```
5.更新apt包索引并安装Docker Engine
```shell
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
6.验证Docker是否正确安装
```shell
sudo docker run hello-world
```
7.安装Docker Compose
```shell
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
```
8.验证Docker Compose是否正确安装
```shell
docker-compose --version
```
阅读全文