for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Time in container gets desychronized after wake up

Open snekcz opened this issue 6 years ago • 22 comments

  • [x] I have tried with the latest version of my channel (Stable or Edge)
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: 23379FB9-A5CD-4FE6-9206-CBF82284EFB0/20200125083318

Expected behavior

Time in containers is always synchonized with the host time.

Actual behavior

Time in container gets desynronized when host put to sleep and then woke up. Actually when host is put to sleep, the time is paused and after wake up it continues from that moment. Actual example: Real time: Sat Jan 25 09:46:07 CET 2020 Time in container: Fri Jan 24 21:25:45 CET 2020

Information

  • Is it reproducible? yes
  • Is the problem new? yes
  • Did the problem appear with an update? yes, just after update to 2.2.0.0
  • Windows Version: Win 10 Pro1903
  • Docker Desktop Version: 2.2.0.0 (42247)
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: no

Steps to reproduce the behavior

  1. Run Docker Desktop
  2. Put host to sleep
  3. Wake up the host after some time
  4. The time is not synchonized
  5. When you restart Docker Desktop, the time is synchronized again

snekcz avatar Jan 25 '20 08:01 snekcz

It is probably the same issue as https://github.com/docker/for-win/issues/4526

snekcz avatar Jan 26 '20 10:01 snekcz

Possibly also #3168

Mikk36 avatar Jan 27 '20 22:01 Mikk36

hadnt even considered sleep as contributing to timing discrepancy between Win/Docker off HyperV.

explains the ~inconsistent deviation I was observing... few hours off one day, none the next.

coip avatar Jan 27 '20 22:01 coip

Since version 2.2.0.0 at least 4 developers in our team have same issues with docker desktop for windows. It's really annoying such goofy bugs in docker.

korvin2000 avatar Jan 28 '20 09:01 korvin2000

I can confirm this.

> date < nul
The current date is: 2020-01-29
> time < nul
The current time is: 15:23:07,65
> docker run --rm -it ubuntu:18.04 /bin/bash
root@c903b00c3da2:/# date
Tue Jan 28 22:47:43 UTC 2020

samerdokas avatar Jan 29 '20 14:01 samerdokas

I can confirm this as well; time drifts every time I put the machine to sleep. My current workaround is something like this

docker run --rm --privileged ubuntu hwclock -s

This may or may not work well depending on whether your Windows machine's hardware clock is set to UTC or to local time, but you may manage to vary this in an appropriate way. See hwclock's documentation for details.

MartinSoto avatar Jan 31 '20 14:01 MartinSoto

Another workaround is to restart the Time Synchronization service (credit @ThorstenHans):

  1. Run PowerShell as administrator
  2. Run command:
    Disable-VMIntegrationService -VMName DockerDesktopVM -Name "Time Synchronization"
    Enable-VMIntegrationService -VMName DockerDesktopVM -Name "Time Synchronization"
    

This should restart the time synchronization service and immediately restore the correct time inside your containers.

aaronadamsCA avatar Feb 03 '20 17:02 aaronadamsCA

Same issue here. I'm using docker for desktop since it was released and never had this issue but since 2-3 days I experienced issues cause "apt-get update failed in the container with:

E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 2h 29min 4s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 15h 27min 25s). Updates for this repository will not be applied.

I'm putting my computer to sleep regularily. Seems to be a bug in Hyper-V?!

EDIT: Seems to be not just a few days but longer as I found this: https://thorsten-hans.com/docker-on-windows-fix-time-synchronization-issue

WolfspiritM avatar Feb 05 '20 09:02 WolfspiritM

can confirm as well. v2.2.0.

iTaybb avatar Feb 05 '20 12:02 iTaybb

Thanks for the reports. We're looking into this. We're not doing anything different here from previously, but we think something has changed in Hyper-V and/or the Linux kernel that we will need to work around.

stephen-turner avatar Feb 10 '20 13:02 stephen-turner

@stephen-turner This problem is not new and exists at least 1 year now, if not even longer. I got used to it restarting docker from time to time.

liayn avatar Feb 17 '20 13:02 liayn

@stephen-turner This problem is not new and exists at least 1 year now, if not even longer. I got used to it restarting docker from time to time.

I cannot fully agree with you, @liayn. First time I have experienced this issue was when I upgraded to 2.2.0.0. I'm now back on 2.1.0.5 beacuse of other issues and time is perfectly in sync all the time. So, it seem to be at least somehow connected to the upgrade.

snekcz avatar Feb 17 '20 13:02 snekcz

@snekcz Good for you. But as I wrote, I have this problem for a much longer time, and colleagues are having them too. (I was always on Dell XPS 9570, latest Win 10 Pro, latest BIOS, and so on)

liayn avatar Feb 17 '20 13:02 liayn

I can confirm I also experience the issue on 2.2.0.3 (42716). A workaround is to restart Docker. However, I believe that it might have something to do with Hyper-V. I noticed the issue when my auth for gsutil failed inside a running container. I had the exact same issue, when trying to authenticate gsutil on a linux VM running on Hyper-V.

pep4eto1211 avatar Feb 17 '20 13:02 pep4eto1211

I can confirm as well, 2.2.1.0 edge.

Very annoying with AWS not liking the timestamps on API requests. @aaronadamsTO's powershell steps gets things back in line.

hvolmer avatar Feb 20 '20 03:02 hvolmer

In release note: https://docs.docker.com/docker-for-windows/release-notes/#docker-desktop-community-2203 Known issues: In some cases, Docker containers do not synchronize time with the host when the host machine is put to sleep.

philippe-granet avatar Mar 06 '20 08:03 philippe-granet

Had the same problem with 2.2, then I've updated Windows to use insider preview version (slow) and it seems to work now.

cluetjen avatar Mar 12 '20 11:03 cluetjen

I am seeing this issue with Docker Desktop 2.2.0.4. The issue goes away if I downgrade to Docker Desktop 2.1.0.5.

case-service_1                |  ---> System.ServiceModel.FaultException: Message Expired ---> WSE066: Timestamp is expired. This indicates a stale message but may also be caused by lack of synchronization between sender and receiver clocks. Make sure the clocks are synchronized or use the timeToleranceInSeconds element in the microsoft.web.services3 configuration section to adjust tolerance for lack of clock synchronization.

rpatrick00 avatar Mar 23 '20 14:03 rpatrick00

This is a dupe of #4526, so I'm going to close this copy. @rpatrick00 There is a new build at https://github.com/docker/for-win/issues/4526#issuecomment-600688253 that you can try.

stephen-turner avatar Mar 23 '20 14:03 stephen-turner

@stephen-turner Thanks, the new build resolves my issue.

rpatrick00 avatar Mar 24 '20 13:03 rpatrick00