移除已经安装的 Docker
sudo apt-get remove docker docker-engine docker.io
安装依赖的库
sudo apt-get install software-properties-common ca-certificates apt-transport-https
导入 Docker 官方 gpg key
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
添加 Docker 官方软件库源
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
更新所有软件库源
sudo apt-get update
安装 Docker
sudo apt-get install docker-ce
后台运行 Docker
sudo systemctl start docker
开机自动启动 Docker
sudo systemctl enable docker
查看 Docker 服务运行状态
sudo systemctl status docker
引用来源:https://linoxide.com/linux-how-to/install-docker-ubuntu/