解决中国镜像更新的时效问题

在 Windows 系统下构建 Ubuntu 的 Docker 时,检查更新报错:

Release file for http://mirrors.aliyun.com/ubuntu/dists/focal-updates/InRelease is not valid yet (invalid for another 6d 2h 57min 19s). Updates for this repository will not be applied.

该问题很有可能是虚拟机暂停导致的,回想一下这个虚拟机上次点暂停就是六天前,,

解决方法,在 apt update 前执行:

RUN echo “Acquire::Check-Valid-Until \”false\”;\nAcquire::Check-Date \”false\”;” | cat > /etc/apt/apt.conf.d/10no–check-valid-until

也试了一下网上的其他解决方法,如增加 -o Acquire::Check-Valid-Until=”false” 参数、修改时间等,均无效

这里意思是忽略镜像的时效检查,参考 https://stackoverflow.com/questions/63526272/release-file-is-not-valid-yet-docker