X 的发布文件无效,但 apt-get 更新中出现错误

Kru*_*lur 5 ubuntu docker docker-for-windows

当尝试构建基于 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.
Run Code Online (Sandbox Code Playgroud)

并且构建失败。我怎样才能解决这个问题?

hob*_*dev 7

请尝试这个命令。

须藤 hwclock --hctosys

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


Kru*_*lur 0

事实证明,Windows 版 Docker 存在时钟漂移问题(可能是由于笔记本电脑睡眠所致)。

解决方案是调整 Docker 中的系统时钟,例如

>docker run --privileged -it ubuntu:20.04 
root@0b05be0fc8b6:/# date +%T -s "12:21:43"
Run Code Online (Sandbox Code Playgroud)

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

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