ubuntu 18.04.1
与官网具体讲解不同,本文略去了大量细节介绍,具体看官方教程
参考链接
docker
相关程序这一步可以不需要,如果新机器的话
sudo apt-get remove docker docker-engine docker.io containerd runc
2. 更新基础依赖
更新
apt
仓库sudo apt-get update
安装基础依赖
sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release
3. 设置
GPG key
这段功能没细看
sudo mkdir -m 0755 -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
sudo apt-get update
[!tip] 如果执行
update
命令报错提示GPG
什么的,可能是下面原因
Your default umask may be incorrectly configured,
preventing detection of the repository public key file.
Try granting read permission for the Docker public key file before updating the package index:
可执行的错误修改代码
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update
latest
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
感觉没什么必要
sudo docker run hello-world
指定版本
1. 列出指定版本
# List the available versions: apt-cache madison docker-ce | awk '{ print $3 }'
可能返回的结果
5:20.10.16~3-0~ubuntu-jammy 5:20.10.15~3-0~ubuntu-jammy 5:20.10.14~3-0~ubuntu-jammy 5:20.10.13~3-0~ubuntu-jammy
2. 选择安装指定版本
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
3. 测试...