ubuntu安装docker
操作系统:ubuntu-22.04.1-desktop-amd64
1. 下载存储库
更新apt包索引和安装包以允许apt在HTTPS上使用存储库
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
2. 添加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
3. 设置存储库
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
4. 安装Docker引擎
4.1 更新apt包索引及安装对应引擎
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
4.2 安装特定版本
4.2.1 列出可用版本
apt-cache madison docker-ce
4.2.2 使用上面红框框选内容安装特定版本
apt-get install docker-ce=5:20.10.14~3-0~ubuntu-jammy docker-ce-cli=5:20.10.14~3-0~ubuntu-jammy containerd.io docker-compose-plugin
5. 拉取hello镜像验证验证
service docker start
docker run hello-world
docker images
出现有下图红框内容即为安装成功