树莓派安装docker遭遇的问题
最近学习树莓派,结合docker的方便,便想在树莓派上安装docker,之前在ubuntu搭建过,这次在raspbian系统上搭建;
参考这篇文章,记录下遇到的一些问题.
问题一
apt-get update报错仓库过期
树莓派不自带计时时钟,除非开机自动同步网络事件,否则重启后时间停在关机的那一刻;
报错如下:
root@raspberrypi:/home/pi# sudo apt-get update
命中:1 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian buster InRelease
获取:2 http://mirrors.tuna.tsinghua.edu.cn/raspberrypi buster InRelease [32.6 kB]
命中:3 https://download.docker.com/linux/raspbian buster InRelease
正在读取软件包列表... 完成
E: http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/dists/buster/InRelease 的 Release 文件已经过期(已经过期了 20小时 42分 52秒)。该仓库的更新将不会应用。
E: http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/dists/buster/InRelease 的 Release 文件已经过期(已经过期了 14小时 51分 41秒)。该仓库的更新将不会应用。
更新时间为当前时间,假设当前时间为2021年7月28日12点半,则执行以下命令:
root@raspberrypi:/home/pi# date -s "20210728 12:30"
2021年 07月 28日 星期三 12:30:00 CST
问题二
apt-get update可能执行太慢
树莓派刚使用时可能采用的源速度比较慢,需要更改源,我的如下:
root@raspberrypi:/home/pi# cat /etc/apt/sources.list
# deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
下面这个源不太清楚,参考其他blog改的.
root@raspberrypi:/home/pi# cat /etc/apt/sources.list.d/raspi.list
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
问题三
curl报错不能解析
root@raspberrypi:/home/pi# curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add -
curl: (6) Could not resolve host: yum.dockerproject.org
gpg: 找不到有效的 OpenPGP 数据。
尝试修改/etc/resolv.conf文件为以下内容:
root@raspberrypi:/home/pi# cat /etc/resolv.conf
# Generated by resolvconf
nameserver 114.114.114.114
nameserver 8.8.8.8
由于对网络配置这块了解不深,采用第二种方法,问题待解决…
最后按照第一种方法,直接一条命令解决:
root@raspberrypi:/home/pi# sudo curl -sSL https://get.docker.com | sh
# Executing docker install script, commit: 7cae5f8b0decc17d6571f9f52eb840fbc13b2737
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sh -c echo "deb [arch=armhf] https://download.docker.com/linux/raspbian buster stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ [ -n ]
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ [ -n 1 ]
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null
+ sh -c docker version
略...
2021-7-28 更新