1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 卸载旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
# 安装前置
sudo apt update
sudo apt-get install ca-certificates curl gnupg lsb-release
# 安装证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# 使用阿里云仓库
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# 安装docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
# 安装docker-compose
sudo apt-get install docker-compose
#添加docker用户组
sudo groupadd docker
#将登陆用户加入到docker用户组中
sudo gpasswd -a $USER docker
#更新用户组
newgrp docker

# 重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker