1. 更新apt缓存
sudo apt update
2. 允许apt通过https协议安装软件
sudo apt install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
3. 添加docker官方的GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4. 添加apt仓库
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
5. 更新apt缓存
sudo apt update
6. 安装docker-ce
sudo apt install docker-ce docker-ce-cli containerd.io
7. 使当前非root用户执行docker命令不加sudo
sudo gpasswd -a ${USER} docker
sudo service docker restart
Docker官方链接