配置好dockerfile后,编译镜像docker build -t my-debian .
报错:
E: Release file for http://mirrors.org/debian/dists/bookworm-updates/InRelease is not valid yet (invalid for another 3h 15min 21s). Updates for this repository will not be applied.
E: Release file for http://mirrors.org/debian/dists/bookworm-backports/InRelease is not valid yet (invalid for another 3h 15min 21s). Updates for this repository will not be applied.
The command '/bin/sh -c echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup && echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99ignore-release-date && apt-get -y update' returned a non-zero code: 100
根本原因是由于 Debian 软件源的 Release 文件的时间戳超前,导致 apt-get update 失败。可能的原因包括:
- 本机系统时间错误:如果你的 Docker 宿主机时间不正确,可能导致这个问题。
- Docker 容器的时间错误:容器内的时间和 Debian 官方服务器的时间不同步。
- 软件源服务器的时间超前:镜像服务器的 Release 文件带有未来的时间戳。
针对第一个问题
本机时间错误,解决方案如下
# 查看宿主机时间
date
# 如果时间比较老,则会导致这个问题
# 更新时间,设置成最新时间即可
date -s "20250207 11:33:00"
针对第二个问题
通过修改dockerfile,配置时区即可,网上有很多教程,不赘述
针对第三个问题
修改软件源即可