环境
目前 Docker 支持的 Ubuntu 版本有:
- Ubuntu Jammy 22.04 (LTS)
- Ubuntu Impish 21.10
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
当前的 Ubuntu 的版本为 20.04.3
。
root@node-11:~# cat /etc/issue
Ubuntu 20.04.3 LTS \n \l
当前的安装用户为:
root@node-11:~# whoami
root
若要使用其他用户安装,该用户需要有 sudo
权限。
Docker Engine 支持 x86_64 (or amd64),armhf,arm64,和 s390x 架构。
在线安装
更新软件列表
apt update
为防止当前环境有旧版本的Docker,首先执行卸载命令:
apt remove -y docker docker-engine docker.io containerd runc
如果卸载命令报告没有没有包要进行删除,表明当前环境未安装 Docker。
root@node-11:~# apt remove docker docker-engine docker.io containerd runc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'docker' is not installed, so not removed
Package 'containerd' is not installed, so not removed
Package 'runc' is not installed, so not removed
Package 'docker.io' is not installed, so not removed
Package 'docker-engine' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 187 not upgraded.
安装需要用到的工具(通常完整版的 Ubuntu 20.04 系统都会自带):
apt install -y ca-certificates curl gnupg lsb-release
添加 Docker 官方的 GPG 密钥
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
添加官方的 Docker 仓库
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
查看仓库文件
root@node-11:~# cat /etc/apt/sources.list.d/docker.list
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu focal stable
更新apt包列表:
apt update
查看软件列表中的 Docker 版本:
apt-cache madison docker-ce
docker-ce | 5:20.10.19~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.18~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.18~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.17~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.17~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.16~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.16~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.15~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.15~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.14~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.14~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.13~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.13~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.12~3-0~ubuntu-focal | https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal/stable amd64 Packages
... 省略其他版本 ...
可以看到目前官方最新的版本为20.10.19
,另外由于我配置了阿里云的Ubuntu
源,可以看到阿里云仓库中的最新版本为20.10.18
。
安装最新版本:
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
安装指定版本:
apt install -y docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin
例如安装 20.10.18版本:
apt install -y docker-ce=5:20.10.18~3-0~ubuntu-focal docker-ce-cli=5:20.10.18~3-0~ubuntu-focal containerd.io docker-compose-plugin
标签:linux,20.10,Ubuntu,ce,20.04,ubuntu,docker,Docker,focal
From: https://www.cnblogs.com/joeblackz/p/16794777.html