1 移除旧版
sudo apt-get remove docker docker-engine docker.io containerd runc
2 设置repo
sudo apt-get install ca-certificates curl gnupg lsb-release sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
3 安装docker
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4 添加当前用户权限
这步是可选的,你也可以都用sudo执行,就没这事了
# 将自己添加到docker组中 sudo groupadd docker sudo gpasswd -a ${USER} docker # 重启后重新load下权限 sudo service docker restart newgrp - docker