首选需要查看树莓派的系统版本

lsb_release -a

看输出字样

Codename就是系统版本类型

更换系统镜像源任选其一

sudo nano /etc/apt/sources.list.d/raspi.list

阿里云

deb http://mirrors.aliyun.com/raspbian/raspbian/ bullseye main contrib non-free rpi
deb http://mirrors.aliyun.com/raspberrypi/ bullseye main

中科大

deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ bullseye main contrib non-free rpi
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/ bullseye main

清华源

deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main contrib non-free rpi

设置好源之后,安装依赖

sudo apt install apt-transport-https ca-certificates curl gnupg2

添加秘钥

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

添加仓库

echo "deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/raspbian bullseye stable" | sudo tee /etc/apt/sources.list.d/docker.list

安装docker

sudo apt update && sudo apt install docker-ce

会提示After this operation, 386 MB of additional disk space will be used ,选择Y,等待安装结束

意外1

如果出现ssl错误,先修复网络

sudo apt install --reinstall ca-certificates
sudo update-ca-certificates

查看版本

docker --version