- 安装依赖
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
- 添加 Docker 官方的 GPG 密钥(为了确认所下载软件包的合法性,需要添加软件源的 GPG 密钥)
# 下面两个二选一即可,推荐使用国内
#(官方)
curl -fsSL https:
#(国内)
curl -fsSL https:
- 设置稳定版本的apt仓库地址
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
- 刷新源
sudo apt-get update
- 查看可用的版本
sudo apt-cache madison docker-ce
apt-cache madison docker-ce | awk '{ print $3 }'
- 安装
sudo apt-get install docker-ce docker-ce-cli containerd.io
VERSION_STRING=5:20.10.13~3-0~ubuntu-jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
- 验证
sudo docker --version
- 设置镜像加速(同CentOS)
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://kfwkfulq.mirror.aliyuncs.com"
]
}
sudo service docker restart
sudo docker info | grep Mirrors -A 4