运行以下命令,更新软件包索引并安装添加 Docker 仓库所需的前置软件包:
sudo apt update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
第 2 步:导入 Docker GPG 密钥
使用以下命令下载并导入 Docker 阿里云的 GPG 密钥:
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
root@webui:/home/webui# curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
向 source.list 中添加Docker软件源
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
root@webui:/home/webui# add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
Repository: 'deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy stable'
Description:
Archive for codename: jammy components: stable
More info: http://mirrors.aliyun.com/docker-ce/linux/ubuntu
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/archive_uri-http_mirrors_aliyun_com_docker-ce_linux_ubuntu-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-http_mirrors_aliyun_com_docker-ce_linux_ubuntu-jammy.list
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
Get:5 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy InRelease [48.8 kB]
Get:6 http://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 Packages [36.9 kB]
Fetched 85.8 kB in 1s (65.6 kB/s)
Reading package lists... Done
W: http://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
再次更新索引包
sudo apt-get update
若想直接安装最新版本执行以下命令即可
sudo apt-get install docker-ce
查看docker版本
apt-cache madison docker-ce
标签:mirrors,ce,apt,aliyun,ubuntu,docker,安装
From: https://www.cnblogs.com/kyo-1115/p/18329429