I am trying to update a ubuntu container with a dockerfile.

RUN apt-get update -y

But I am getting the below error.

E: Release file for http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease is not valid yet (invalid for another 9h 14min 10s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease is not valid yet (invalid for another 9h 14min 16s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease is not valid yet (invalid for another 9h 14min 35s). Updates for this repository will not be applied.

I checked some other solutions to the same problem like adding Acquire::Check-Valid-Until=false to apt-get like below

RUN apt-get -o Acquire::Check-Valid-Until="false" update -y

The above also fails.

  • 4
    Check your system clock (or a mismatch between your system timezone & clock)
    – guiverc
    Commented Jul 25, 2018 at 3:54
  • 1
    @guiverc yes updating the local time worked
    – Shash
    Commented Jul 25, 2018 at 4:43
  • @Shash If it worked, then please accept the submitted answer so that people will know that it worked for you!
    – devinbost
    Commented Mar 20, 2019 at 20:56

8 Answers 8


Restart docker (or your computer to be certain) as the system clock is mismatched.

I spent few hours trying to figure what was going and restarting fixed it instantly.

  • 2
    This solved the problem for me too
    – Turp
    Commented Apr 3, 2020 at 3:08
  • If you have the NTP daemon or an equivalent installed, it fixes the clock on a reboot, so that would be why it works. Commented May 15, 2021 at 3:46
  • 4
    For Windows users having Docker with wsl backend: I also needed to reboot wsl using wsl --shutdown and then rebooting docker host.
    – Guido
    Commented May 17, 2021 at 7:51
  • Same for me with podman, had to do podman machine stop && podman machine start Commented Mar 7, 2023 at 8:50
  • I am using podman, I restart podman machine stop and start and the issue resolve
    – Kernelv5
    Commented Mar 8, 2023 at 16:16

Correct your system clock. (in comments I also suggested checking for a mismatch between clock and your timezone too)

Refer to What is the command line statement for changing the System clock? for setting system time (I suggest going to the timedatectl answer if using a 'modern' Ubuntu release), or http://manpages.ubuntu.com/manpages/xenial/man8/hwclock.8.html (if you want to set hardware clock directly; but remember to match it up with your timezone config)

  • 6
    The system clock can be off after you put a virtual machine to sleep... that's what happened to me...
    – sdittmar
    Commented Aug 2, 2020 at 14:35
  • timedatectl didn't solve the problem for me. I get the below error root@d8e0b021f7d8:/# timedatectl System has not been booted with systemd as init system (PID 1). Can't operate. Failed to create bus connection: Host is down root@d8e0b021f7d8:/#
    – Dinesh
    Commented Oct 12, 2020 at 3:28
  • 4
    Quick command to fix clock: sudo systemctl restart systemd-timesyncd.service Commented Aug 24, 2021 at 16:31

I've solved my issue with updating time:

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
sudo apt update
  • 2
    Finally, the right answer to my problem. Thanks bro
    – Sabrina
    Commented Dec 17, 2019 at 13:28
  • It should be the accepted answer. It's the fastest and easiest way to update your system clock. Commented Dec 21, 2019 at 22:24
  • and in fact, the only answer that worked for me. Restarting did nothing.
    – Brad
    Commented Nov 6, 2021 at 14:00
  • I would like to thank and congratulate you for this being the sole correct answer I've found on Stack Exchange, for any linux problem, in a week, literally seven consecutive days, of all-day and all-night troubleshooting. Thanks!
    – John Smith
    Commented Nov 9, 2023 at 8:23

If you are using Docker, a bug was recently introduced in 2.2.0 that causes time drift when the host computer goes to sleep. This desynchronizes all running docker containers, resulting in errors such as this one.

See https://github.com/docker/for-win/issues/5593 for tracking the solution and workarounds.

This was asked in 2018, when this bug was not present in Docker yet. Now, this bug is present, so this bug may be the problem for people finding this post today.

  • This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
    – David
    Commented Feb 5, 2020 at 23:30
  • 3
    Hi @David. It is not an answer to OP, purely because OP asked this in 2018, when this bug was not present in Docker yet. Now, this bug is present, and this StackOverflow question is the first hit in Google when searching for "docker Release file is not valid yet". Therefore, the answer is useful to everyone visiting, as it is a solution for the problem posted above, even if the root cause for the original poster was something different. Commented Feb 7, 2020 at 9:01
  • Do you prefer I open a new question and answer my own question instead? Commented Feb 7, 2020 at 9:04
  • It should be noted that this is specific to Docker Desktop on Windows. The solution based on Ruben's answer is simply to "restart Docker Desktop". Commented Mar 24, 2020 at 12:11

This didn't work for me:

apt-get -o Acquire::Check-Valid-Until="false" update

but this did:

apt-get -o Acquire::Max-FutureTime=86400 update

86400 is the number of seconds in a day. If your clock is off more than that, you will need to increase it.

Warning: Quotes can cause it to treat the number as a string. The shell will normally remove one set of quotes, but -o 'Acquire::Max-FutureTime="86400"' would only have the single quotes removed by the shell, and apt-get would see the double quotes around the number.

I tried this because GetNotBefore() in acquire-item.cc returns d->NotBefore which seems to only be affected Acquire::Max-FutureTime.

https://github.com/Debian/apt/blob/master/apt-pkg/acquire-item.cc#L1758-L1775 https://github.com/Debian/apt/blob/master/apt-pkg/deb/debmetaindex.cc#L543-L555

  • This helped me install the update but didn't solve the issue
    – Dinesh
    Commented Oct 12, 2020 at 3:14
  • @Dinesh, looking at your other comments, I see that you are still trying to solve the time setting inside the docker container. If your docker host is linux, you should be able just fix the time on that linux system, but when running Docker Desktop for Windows, it is running the linux docker host inside a VM. In order for your container to change the time with hwclock, you need to run the container with --cap-add=SYS_TIME. However, every minute, the docker host will reset the time. ivankrizsan.se/2015/10/31/time-in-docker-containers
    – egrubbs
    Commented Nov 9, 2020 at 16:09
  • @Dinesh With Docker Desktop for Windows, you can gain access to the docker host by following these instructions. However, the host uses Moby Linux which is very different from most other distributions. github.com/justincormack/nsenter1
    – egrubbs
    Commented Nov 9, 2020 at 16:13
  • @Dinesh If you want to adjust the time in a specific container without adjusting it for all the containers and the host, you can use libfaketime. github.com/wolfcw/libfaketime
    – egrubbs
    Commented Nov 9, 2020 at 16:16
  • This helped me update my Debian sid testbed box. I had to increase the number by like 21 days though. Commented Mar 27, 2021 at 15:46

This helped me to fix time in docker:

docker run --rm --privileged alpine hwclock -s
  • This should be the correct answer.
    – noomz
    Commented Jan 27, 2021 at 14:01
sudo hwclock -s

helped fix the issue for me.

Docker running on WSL 2 Windows 10 19603

  • I tried "sudo hwclock -s --verbose" and got this error "No usable clock interface found"
    – Dinesh
    Commented Oct 12, 2020 at 3:14
  • This fixed the issue for me +1
    – Eng.Fouad
    Commented Apr 19, 2021 at 20:22

On Docker Desktop:

Settings → Reset → Reset to factory

  • This was the only thing that worked for me. Thank you!
    – mmell
    Commented Apr 2, 2020 at 23:56
  • Troubleshoot→ Restart did it for me
    – maeneak
    Commented Apr 28, 2020 at 9:53
  • I am using Version 2.4 and "Reset to factory defaults" is found under Troubleshoot. But reset didn't solve the problem for me.
    – Dinesh
    Commented Oct 12, 2020 at 3:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .