apt-get update 报错:Release file for X is not valid yet。

5
尝试构建基于Ubuntu的Docker容器(Docker for Windows)时,突然出现一个类似以下错误的错误:
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease is not valid yet (invalid for another 9h 55min 59s). Updates for this repository will not be applied.

编译失败了,我该如何解决?

3个回答

7
请尝试执行以下命令:

sudo hwclock --hctosys

我通过上述命令修复了错误。

1

这只涉及日期和时间,我的已经固定为:

sudo service ntp restart

0
原来Docker for Windows存在时钟漂移问题(可能是由于笔记本电脑休眠引起的)。
解决方案是在Docker中调整系统时钟,例如:
>docker run --privileged -it ubuntu:20.04 
root@0b05be0fc8b6:/# date +%T -s "12:21:43"

假设“12:21:43”是UTC当前时间。

编辑:问题再次出现,似乎与Hyper-V和笔记本电脑低电池睡眠有关。我升级了最新的Windows 10,并将Docker切换到使用WSL2而不是已弃用的Hyper-V,问题终于解决了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接