ubuntu 18.04.1
与官网具体讲解不同,本文略去了大量细节介绍,具体看官方教程
参考链接
这一步可以不需要,如果新机器的话
sudo apt-get remove docker docker-engine docker.io containerd runc
更新
apt
仓库sudo apt-get update
安装基础依赖
sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release
这段功能没细看
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
这段代码也没细看,官网表示跟着输入就行
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
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
感觉没什么必要
sudo docker run hello-world
# 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
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