参考连接:https://ywnz.com/linuxjc/3949.html
1、查看ubuntu版本
cat /etc/lsb-release

2、卸载可能存在的旧版本docker
sudo apt-get remove docker docker-engine docker-ce docker.io
3、更新apt包
sudo apt-get update
4、切换到root权限
sudo -i
5、安装以下包以使apt可以通过HTTPS使用存储库(repository)
apt-get install apt-transport-https \
ca-certificates \
curl \
software-properties-common
6、添加Docker官方的GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

7、安装稳定存储库
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \stable"
出现问题1):Command 'add-apt-repository' not found, but can be installed with

问题2):
Err:6 https://download.docker.com/linux/ubuntu \ Release
404 Not Found [IP: 13.32.52.25 443]

》》解决办法:
打开sources.list:vim /etc/apt/sources.list
增加这条:deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

保存退出后更新apt 源:apt-get update
查看docker-ce这个安装包:apt search docker-ce

8、安装最新版本Docker CE(社区版)
sudo apt-get install docker-ce
9、查看docker版本
docker version

问题3:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
》》解决办法:
网上给的解决方案是systemctl daemon-reload,但是我这报错

根据错误提示打开/etc/docker,这个文件夹里没有daemon

于是便安装一个: apt-get install daemon
安装好后,再在文件夹/etc/docker里新建一个daemon.json文件:touch daemon.json
编辑daemon.json:vim daemon.json

保持退出后,启动docker并查看docker状态、docker版本:


至此,Ubuntu20.04安装docker结束~
网友评论