一 如果安装失败用二安装

1.先卸载旧版,如果没有的话,就不用执行了,直接第二步。

apt-get remove docker docker-engine docker.io containerd runc
2.在终端输入

apt update
apt-get install ca-certificates curl gnupg lsb-release
3.安装证书

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4.写入软件源信息

sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"


5.安装

sudo apt-get install docker-ce docker-ce-cli containerd.io
中途出现问题的话,使用 sudo apt-get update 试试

6.启动docker

systemctl start docker
7.安装工具

apt-get -y install apt-transport-https ca-certificates curl software-properties-common
8.重启docker

service docker restart
9.测试是否成功,输入sudo docker run hello-world 显示以下信息则成功,第一次比较慢。

 

10.查看docker版本

sudo docker version
11.查看镜像,可以看到刚才创建的镜像

sudo docker images

二  安装docker

更新现有的软件包列表
sudo apt update
1
下载必要软件
sudo apt install apt-transport-https ca-certificates curl software-properties-common
1
将官方 Docker 版本库的 GPG 密钥添加到系统中
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
1
Docker版本库添加到APT源
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
1
更新软件包
sudo apt update
1
确保要从 Docker 版本库,而不是默认的 Ubuntu 版本库进行安装
apt-cache policy docker-ce
1
安装 Docker
sudo apt install docker-ce
1
检查 Docker 是否正在运行
sudo systemctl status docker
————————————————