1-更新 apt 包索引
sudo apt update
2-安装依赖包
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
3-添加阿里云的Docker CE仓库的GPG密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4-添加阿里云的仓库
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
5-更新APT包索引
sudo apt-get update
6-安装Docker CE
sudo apt-get install docker-ce docker-ce-cli containerd.io
参考:Ubuntu 20.04 安装docker(傻瓜试一键教程)
---------------------------------------------------------------------------------------------------------
补充说明:
按照参考链接的安装方式:添加 Docker 的官方 GPG 密钥和官方安装会报错
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease
Hit:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease
Hit:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease
Ign:4 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:5 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease
Err:6 https://download.docker.com/linux/ubuntu bionic Release
Could not handshake: Error in the pull function. [IP: 2600:9000:234b:c600:3:db06:4200:93a1 443]
Ign:7 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu bionic InRelease
Hit:8 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu bionic Release
Hit:10 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Hit:11 http://ppa.launchpad.net/ubuntu-desktop/ubuntu-make/ubuntu bionic InRelease
Reading package lists... Done
E: The repository 'https://download.docker.com/linux/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.