-
Notifications
You must be signed in to change notification settings - Fork 117
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
Time drift on MacOS #2076
Comments
Time is currently set by 2 mechanisms:
I'm not sure what's allowing it to drift in your case. Perhaps the machine wakes, and runs When next in this state, could you log into the VM with:
and then query the NTP state with
|
@djs55 sure - will do. Also, please note that my system never went to sleep. And, I know this to be the case because I just installed OS X 10.13 the day before. But, I also rarely put the system to sleep in general. |
I'm also seeing this - output captured below:
27secs of drift:
|
Seeing this as well
|
I'm also seeing considerable drift of several minutes on macOS 10.13.1 (17B46a). My system is always on, I only set the screens to sleep when I'm away from the computer.
I also noticed that the chrony drift file can't be written because of a missing directory:
This probably doesn't matter much, since it only affects initial clock drift correction after chronyd restarts. One interesting thing to note though is that the hwclock in the VM is not drifting, but the system time is drifting from RTC. This indicates that the clock provider is doing a bad job. Currently it is using the TSC time source, it might make sense to experiment with other providers like hpet or acpi_pm. There are various post on the web with TSC causing trouble on HyperV, os it is likely it affects other hypervisors as well.
I'll try experimenting with hpet first and see if that helps and try acpi_pm next. The clocksource can be changed at runtime:
If your VMs system time currently drifts from the rtc, sync it back after switching the clocksource:
I found lots of useful info under the following links: |
Same here, with a drift of 16 minutes. Fixed by restarting Docker.
|
Btw. none of the available clocksources fixed the time drift problem for me. |
I'm seeing a pretty consistent drift of about 1-2ms per second. This is pretty consistent. Resetting the clock time just changes the time, it doesn't address the drift. |
Same problem on Version 17.09.1-ce-mac42 (21090), Channel: stable, 3176a6af01. My PostgreSQL container's clock gains several seconds in the future every time I wake up my MacBook Pro from sleep. I love Docker, but having to restart it so often is really annoying... Let me know if I can help in any way. |
@adrienjoly - here is a tip: |
@buchs Thanks for the tip! But isn't there a risk of altering data integrity of my PostgreSQL database running on that container, if I change the time without rebooting? |
Hmm, interesting question. If you are timestamping entries, and you turn the docker server clock back, you might have issues. What else can you do in a database to cause problems? Constraints based on time? Maybe the log would turn out funny, if you needed to do a recovery. It all depends on what and how you use the database, I suppose. |
You're right, changing the time will cause wrong timestamps in our data. That's not that bad for a development environment. |
I'm seeing the same issue using a Python image. Note that some servers refuse to authenticate my client due to the time disparity! At present a 13 second disparity:
The |
My clock is drifting roughly 2.5 seconds every minute.
|
Here is the bash script I use on my Mac to restart Docker when needed:
|
Also seeing very heavy drift.
|
Recent versions of Docker for Mac have removed easy access to the "restart" button which was useful for fixing this |
After an upgrade from 17.09.0-ce-mac35 (19611) to 17.12.0-ce-mac49 (21995) yesterday, I've started noticing heavy drifting on Mac OS 10.11.6. The only other change was that the host machine was rebooted just before the upgrade (but no OS patches applied). I'm developing a time sensitive application which immediately starts triggering protection mechanisms if time is more than 5 seconds away from an external source. It could be fixed by running Edit: First noticed it ~09:25 today, at which time it had ~30s drift, corrected with |
I upgraded another computer that previously wasn't showing drift to 17.12.0-ce-mac, and then it too started showing drift. It's drifting in a really strange way too. Try this:
while true; do date; sleep 10; done
For example, after a while my host will output: Same times, but the container is delayed ever longer as time goes on. The times will always match, but the container falls further and further into the past. It seems like time is moving more slowly in Containerlandia. |
I've attached a bash script,
Here's most of the commentary from the script. This commentary includes actual output from my MacBook Pro showing at least a second of drift within an hour of the synchronization step.
Perhaps a simpler way to say that is to note that guest emitted timestamp Here's the script, so named so that I could attach it: dfm-drift.txt
|
@hughsw I'm seeing something similar, when I add an iteration count so I can match the timestamps:
I'm seeing two weird things:
Like so: Container iteration 1: Thu Jan 25 12:48:09 PST 2018 ....time passes.... Container iteration 640: Thu Jan 25 14:34:11 PST 2018 Watching the system clock, the host is outputting at the correct time. |
@thinkspill Your script doesn't execute exactly every 10 seconds, so you have to be very careful about drawing conclusions that may assume that it does execute exactly every 10 seconds. That is, the wall-clock time it takes for the loop's scripting logic to execute and for I wrote the Python script in my test above to wait until the Unix clock rolls over each second before sampling the clock and emitting it. This makes it a little easier to draw conclusions about the drift. |
Another test:
Executed in a
So after 101 minutes, it's -1.88s off Edit:
Edit 2:
Then, for some reason, it started to log 0.00000s offset.. until it after a while started spewing out |
@djs55, i'm trying it now, thanks! |
@djs55 so far so good on development build mentioned above, will try out some other use cases today just to see how broadly functional this fix is. thanks again! |
@djs55 looking good here, running for about 24 hours now.
|
i would say this solves it for me, looking forward to when it lands in the official release, thanks @djs55! best, mike. |
Is this slated for this quarter's stable release? |
@timkeeler the fix should be in edge |
I hope so and how much this is a problem for me might just jump to a unstable version to get around these issues. |
@tmack8001 been running this for about 3 weeks or so now and it seems to have fully resolved the issue. I'm going ahead and closing this. |
Any idea when this fix is going to hit a stable release? Right now seems to be the longest period in Docker For Mac's history without a stable release! |
@ThatLarsGuy the next stable Desktop release should coincide with the 18.06 engine release. The edge channel currently has |
Not to kick a dead horse (but also, I will, because why else would I be on this thread). This timing bug is a bit long-lived at this point; seriously, it is years long and there's issue history to back that up. Let's get it released already! 🚀 |
This is enough of a problem for me that I ended up making a docker image to address it until a real fix gets released. Still in the middle of testing it myself, but so far it seems to work well for me: https://hub.docker.com/r/eshork/docker-mac-chrony/ It's a really simple solution. I'm honestly not sure why this doesn't already exist somewhere else. Perhaps I simply didn't stumble across the appropriate google result... Either way, if it helps one other person, that makes it worth while. |
Release notes for Docker for Mac stable release, version
|
@JohnRGee thanks for highlighting this -- the fix has indeed been released on both stable and edge channels. Hopefully this is fixed for everyone. If not, please do open a fresh ticket with a set of diagnostics. Thanks all for your patience! |
Closed issues are locked after 30 days of inactivity. 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. |
Version 17.06.2-ce-mac27 (19124)
Can confirm that there is time drift on the Docker client for Mac. I was able to confirm that restarting the Docker client corrects the time issue. Issue is present across all docker containers and
docker run busybox date
.There are quite a few reports of this on previous versions. And it was supposedly fixed, but it is not.
The time being off here was only about a minute prior to restarting the Docker client. I cannot say how far it would have been off had the host been put to sleep. In fact, that may have triggered an update and corrected the issue.
It seems the VM clock emulation is just not accurate. Is the VM not using NTP? Can we not have a cron re-sync regularly, even without a Docker client interruption?
The text was updated successfully, but these errors were encountered: