手机刷了 mobian 想安装 docker,记录安装过程中的一些问题
1. 更新软件包列表
sudo apt-get update
2. 安装依赖包
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
3. 添加 Docker 的官方GPG密钥
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. 设置 Docker 的apt存储库
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
由于我当前系统的版本是 debian trixie,docker 官方暂时没有这个版本的软件包,所以把上述命令中的 $(lsb_release -cs)
改为 bookworm
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. 更新软件包列表
sudo apt-get update
6. 安装 Docker Engine
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
7. 配置国内的 docker 镜像源
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://hub.atomgit.com"]
}
EOF
8. 重启 docker 服务
systemctl daemon-reload
systemctl restart docker
这时重启出现报错
用 dockerd
命令查看报错信息
WARN[2024-10-28T00:41:21.508636677+06:00] failed to find iptables error="exec: \"iptables\": executable file not found in $PATH"
INFO[2024-10-28T00:41:21.512342948+06:00] stopping event stream following graceful shutdown error="<nil>" module=libcontainerd namespace=moby
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to register "bridge" driver: failed to create NAT chain DOCKER: iptables not found
看报错信息是没有找到 iptables,用 sudo apt install iptables
命令安装 iptables 后重启依然失败,不知道是不是因为没有设置环境变量,但是参考其他博主用下面两条命令解决了
https://www.cnblogs.com/zuiyixin/p/17169350.html
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy#启动命令
sudo service docker start
9.验证 Docker 是否正常运作
sudo docker run hello-world