- 卸载之前的docker
sudo apt-get remove docker docker-engine docker.io containerd runc
2.安装依赖
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
3.添加 Docker 的阿里云GPG 密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4.安装docker-ce
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
5.启动docker
sudo systemctl enable docker
sudo systemctl start docker
6.建立 docker 用户组
sudo groupadd docker
sudo usermod -aG docker 用户名
7.测试
sudo docker version