Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong date/time again #4526

Closed
2 tasks done
davclark opened this issue Aug 14, 2019 · 87 comments
Closed
2 tasks done

Wrong date/time again #4526

davclark opened this issue Aug 14, 2019 · 87 comments
Assignees

Comments

@davclark
Copy link

davclark commented Aug 14, 2019

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID: 4FDC213A-B7D0-4570-9113-B53E41EE1C7C/20190814201017

Expected behavior

Time remains correct relative to host. This has been discussed already in #72

Actual behavior

During sleep, Docker Hyper-V VM slowly drifts out of sync with host time.

Information

The problem appears to be a re-emergence of #72. Another individual posted a similar comment at the end of #72. It appears to happen reliably during sleep. It only ends up being important when things happen that require time to be coherent with the real world. For example, this can mess up apt update.

  • Windows Version: 10 Pro 1903
  • Docker Desktop Version: 2.1.1.0

Steps to reproduce the behavior

  1. Run Docker for Windows
  2. Sleep the machine for a while
  3. Observe that time gets out of sync

You can check time on the Docker VM like:

docker run -it --rm ubuntu:18.04 date

You can get UTC on Windows PowerShell like:

$Time = Get-Date
$Time.ToUniversalTime()

There is a small chance that this is affected by setting the Windows hardware clock to UTC (which I suspect many Docker users do - since it makes dual-booting linux easier) [per @echadwickb's comment below]

@echadwickb
Copy link

I am also noticing a clock drift when I sleep my host windows machine. I just checked the registry and I am not setting my hardware clock to UTC (I am missing the "RealTimeIsUniversal" key referenced in this post: https://superuser.com/questions/975717/does-windows-10-support-utc-as-bios-time).

I noticed this problem after upgrading to Docker Desktop Version: 2.1.1.0. The mitigation so far is to restart docker desktop post-wake.

@ajkasper
Copy link

If you get fed up of restarting Docker Desktop it's a bit quicker to go into Hyper-V Manager, go to the settings of the docker desktop VM, and un-check and re-check the "Time synchronization" setting under "Integration Services". Fingers crossed for a quick resolution to this one! :-)

@djs55 djs55 self-assigned this Aug 27, 2019
@djs55
Copy link

djs55 commented Aug 27, 2019

Thanks for the reports. The recent release upgraded the Linux kernel and the Hyper-V time sync strategy is (unfortunately!) different there. We now run a chronyd configured to use Hyper-V as a high-precision time source -- this should be keeping a synchronised system synchronised. It sounds like we're missing a piece to proactively bump the clock forward when the VM wakes from sleep. I'll investigate -- perhaps we're missing a Hyper-V integration service component?

@Rockgecko
Copy link

Any news on when a docker desktop update will appear that fixes this? Should we revert to an earlier version?

@denglund
Copy link

denglund commented Oct 8, 2019

When this happens, the Time Synchronization integration service in Hyper-V gets into a "Lost Communication" state.

image

For those who don't want to check/uncheck the Time Synchronization service every time, running these two commands is the equivalent of that:

Get-VMIntegrationService -VMName DockerDesktopVM -Name "Time Synchronization" | Disable-VMIntegrationService
Get-VMIntegrationService -VMName DockerDesktopVM -Name "Time Synchronization" | Enable-VMIntegrationService

I saved that off in a Powershell script and configured a task in Task Scheduler to run that script on system resume. I tested parts of it, but I'm not 100% sure it'll fix the issue.

@qubitron
Copy link

I am experiencing this issue as well. I did check to make sure I have the Time Synchronization box checked in hyper-v. For me this manifests itself when building containers using apt-get, the apt-get instructions fail:

E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 2h 56min 42s). 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 2h 3min 57s). Updates for this repository will not be applied.

This is from a Python image, see the Dockerfile here.

@bartlomiejcieszkowski
Copy link

Ive got repro of this issue with:
Edge 2.1.7.0 (41536)

Steps to reproduce:

  1. Start os and docker desktop
  2. Hibernate
  3. Wake up next day - start container
    Clock is where it was last day.

Ive checked and the Time Synchronization for DockerDesktopVM is Enabled with Ok status

@namado
Copy link

namado commented Jan 24, 2020

This is happening to me with:

  • Docker Desktop Version 2.2.0.0 (42247)
  • Channel: Stable
  • Engine: 19.03.5
  • Windows 10 Version 1909 (OS Build 18363.592)
C:\Code> docker run --rm -it --entrypoint=/bin/bash app:linux
bash-4.2# date
Thu Jan 23 22:03:25 UTC 2020
bash-4.2# exit
exit
C:\Code> date

Friday, 24 January, 2020 10:59:30

C:\Code> timezone

Id                         : GMT Standard Time
DisplayName                : (UTC+00:00) Dublin, Edinburgh, Lisbon, London
StandardName               : GMT Standard Time
DaylightName               : GMT Daylight Time
BaseUtcOffset              : 00:00:00
SupportsDaylightSavingTime : True

I noted it after the PC was on sleep mode as well.

@benedery
Copy link

also have this problem, make life hard with mage usage inside the container.

@bharling
Copy link

bharling commented Feb 5, 2020

Also seeing this after upgrade to version 2.2.0.0 - containers report totally wrong system times after a while. Didn't see this behaviour in previous versions.

@wulfsolter
Copy link

Hacky workaround/fix that extends off #4526 (comment) is to run that on every resume/wake. https://sumtips.com/how-to/run-program-windows-wakes-up-sleep-hibernate/

Resyncs the host:docker clocks every time you open the lid of the laptop.

@FilipChalupa
Copy link

FilipChalupa commented Feb 6, 2020

Based on #4526 (comment) this gist sync_docker_time.ps1 requests elevated priviliges and synchronizes the time.

sync

@LaurentLesle
Copy link

I am running 2.2.0.1 with wsl2 integration enabled. Has someone found a workaround for wsl2 integration as there is no more VM running.

image

@cdalexndr
Copy link

cdalexndr commented Feb 21, 2020

2.2.0.3, the clock resumes after sleep were it left off, no sync.
This happens when there are no regression tests to keep a previous fix working.

@blmille1
Copy link

I have to toggle the Time Synchronization option every day when I start working or my AWS tools refuse to use my new credentials.

@akuma8
Copy link

akuma8 commented Mar 4, 2020

I have the same issue. I was going crazy because I couldn't understand why my Keycloak server (running in a container) was sending me back expired tokens.

Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:22:37 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:29:19 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@philippe-granet
Copy link

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.

@blmille1
Copy link

blmille1 commented Mar 9, 2020

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.

It's nice that they acknowledge it, but when will it be fixed? This affects me and many others on a daily basis.

@mat007
Copy link
Member

mat007 commented Mar 9, 2020

This will be fixed in the next release, we’re not sure yet when but we’re hoping it will be a matter of days.
In the meantime here is a link to an internal build for a Stable 2.2.0.4 RC which includes the fix: https://download-stage.docker.com/win/stable/43291/Docker%20Desktop%20Installer.exe
We’d be very interested in getting any feedback on whether this fixes it for you.
Thanks!

@SiliconKid
Copy link

This will be fixed in the next release, we’re not sure yet when but we’re hoping it will be a matter of days.
In the meantime here is a link to an internal build for a Stable 2.1.0.4 RC which includes the fix: https://download-stage.docker.com/win/stable/43291/Docker%20Desktop%20Installer.exe
We’d be very interested in getting any feedback on whether this fixes it for you.
Thanks!

Thanks for that, but is that actually a link to a stable 2.2.0.4 RC build?

I assume that's what you meant?

@mat007
Copy link
Member

mat007 commented Mar 11, 2020

Thanks for that, but is that actually a link to a stable 2.2.0.4 RC build?

Indeed, sorry about that, I’ll fix my comment!

@alex-pravdin-sn
Copy link

@SiliconKid I've run the suggested installer and it failed to update my current installation:

The process cannot access the file 'C:\Program Files\Docker\Docker\resources\docker-desktop.iso' because it is being used by another process.

Check the installation, please.

@LaurentLesle
Copy link

I installed the 2.2.0.4 RC, rebooted my windows 10. I am using the wsl2 integration. I put the computer on sleep mode couple of times in the recent days and when working today I see a gaps between the wsl date UTC time on the local computer and the one in the container resuming from sleep. Note starting a new container also shows the wrong date.

The date from the left is from the wsl on the local machine and is correct. the one from the right are from containers

image

@sebastianhaberey
Copy link

Saw it again this morning on 2.3.0.2 (45183) stable.

@ankitbko
Copy link

Maybe this is related to microsoft/WSL#4245

@simonferquel
Copy link

@sebastianhaberey are you running the wsl2 or hyper-v backend?

@sebastianhaberey
Copy link

@simonferquel hyper-v (my Windows 10 build is too low for WSL-2)

@simonferquel
Copy link

Then @djs55 I think we still have work to do on this subject :/

@polys
Copy link

polys commented May 28, 2020

I'm afraid I started seeing this issue again too with 2.3.0.2 and 2.3.0.3 on Hyper-V.

This was resolved for me since @djs55's early patch (based on 2.2.0.4) from mid-March and all subsequent releases.

The only changes in my environment recently were Windows updates (currently on 1909, build 18363.836) and the various Docker Desktop releases (currently on 2.3.0.3 stable).

@djs55
Copy link

djs55 commented Jul 14, 2020

Hi, I've got another experimental build based on Edge which aims to fix clock sync problems with Hyper-V: https://desktop-stage.docker.com/win/edge/46615/Docker%20Desktop%20Installer.exe . This new build runs a custom NTP server on the host and connects to it from the VM, rather than trying to use the kernel support (which seems flakey). This is the same approach we use on Mac. If anyone has a chance to try it, let me know how it goes!

@sebastianhaberey
Copy link

Downloading it now. Will post here if I encounter time-related issues.

@LaurentLesle
Copy link

LaurentLesle commented Jul 16, 2020 via email

@sebastianhaberey
Copy link

Ok this is probably totally unrelated but the whole company is complaining about their system clocks being off, starting yesterday. 😅

@Pankaj-Thakur
Copy link

Pankaj-Thakur commented Aug 13, 2020

I used https://desktop-stage.docker.com/win/edge/46615/Docker%20Desktop%20Installer.exe which runs a custom NTP server on the host and connects to it from the VM, rather than trying to use the kernel support (which seems flakey).
It fixed the issue! The container ahead by 7 hours earlier showed the host time. Thank you @djs55
Note: This welcome behavior did not last after a host or container restart. After container restart the container time started at the creation time of the image.
The fixed time that did not last.
image

@kierenj
Copy link

kierenj commented Sep 28, 2020

Am running:

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:43:18 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:49:27 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Restarting Docker for Windows doesn't fix the issue. Is there another workaround?

@ankitbko
Copy link

If you have wsl2 integration enabled, open wsl bash and type sudo hwclock -s.

@djs55
Copy link

djs55 commented Sep 30, 2020

For Hyper-V mode + Linux containers (not WSL 2 and not Windows containers) the latest fixes have been released in 2.4.0.0 stable.

If there are still problems with Hyper-V mode + Linux containers, let me know!

Problems with timekeeping in WSL 2 should be reported to Microsoft here: https://github.com/Microsoft/WSL

Problems with timekeeping in Windows containers should probably be reported here: https://github.com/moby/moby (and would probably refer to the Windows hcsshim)

@jimjam-slam
Copy link

Thanks for your patience with this issue! 🎉

@mxsxs2
Copy link

mxsxs2 commented Oct 14, 2020

I haven't noticed the sleep/wake issue that was mentioned earlier. I have an issue with daylight saving instead:
The system (Windows 10) time zone is on (UTC +00:00) Dublin, Edinburgh, Lisbon, London with "Adjust for daylight saving time automatically" enabled and my alpine container reflects the time zone but not the daylight saving. If I turn of "Adjust for daylight saving time automatically" then the time is the same.

My docker container seems to be exactly an hour behind:
image

Docker Desktop version is 2.4.1.0(48583) using Hyper-V

@stephen-turner
Copy link
Contributor

Are you sure Alpine reflects the timezone? Maybe it's just pinned to UTC.

@mxsxs2
Copy link

mxsxs2 commented Oct 14, 2020

Are you sure Alpine reflects the timezone? Maybe it's just pinned to UTC.

@stephen-turner It seems to be setting the right time of the host's time zone but it does not show the offset.

If I change to UTC+1 it brings the time forward one hour in the container but there is still an hour difference between the container and the host due to daylight saving.
image

@stephen-turner
Copy link
Contributor

stephen-turner commented Oct 14, 2020

I don't see anything wrong here. I set my timezone to US Eastern and got this:

PS C:\Users\User> Get-Date
14 October 2020 12:58:57

PS C:\Users\User> docker run -it alpine date +"%T %Z %z"
16:59:03 UTC +0000

This is normal. It is expected that the timezone isn't passed into the container.

@stephen-turner
Copy link
Contributor

As the main issue in this ticket was fixed in the 2.4 release, I'm going to close the ticket.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests