Ubuntu在线安装指定版本Docker

76 阅读1分钟

本文由 简悦 SimpRead 转码, 原文地址 segmentfault.com

1、删除 docker 相关组件

sudo apt-get autoremove docker docker-ce docker-engine  docker.io  containerd runc

2、更新 apt-get

sudo apt-get update

3、安装 apt 依赖包,用于通过 HTTPS 来获取仓库

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

4、添加 Docker 的官方 GPG 密钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

5、设置稳定版仓库 (添加到 / etc/apt/sources.list 中)

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

6、更新 apt-get

sudo apt-get update

7、查询 docker-ce 版本

sudo apt-cache policy docker-ce

8、安装指定版本

sudo apt-get install docker-ce=5:23.0.1-1~ubuntu.20.04~focal docker-ce-cli=5:23.0.1-1~ubuntu.20.04~focal containerd.io

9、验证安装是否成功

docker -version