Correct time inside container; ideally matches the host machine
Actual behavior
Time inside is roughly 1 day behind
Information
the output of:
Moby Menu > Diagnose & Feedback on OSX
Docker for Mac: version: mac-v1.12.0-beta16.2
OS X: version 10.11.5 (build: 15F34)
logs: /tmp/20160624-131908.tar.gz
failure: No error was detected
[OK] docker-cli
[OK] app
[OK] menubar
[OK] virtualization
[OK] system
[OK] osxfs
[OK] db
[OK] slirp
[OK] moby-console
[OK] logs
[OK] vmnetd
[OK] env
[OK] moby
[OK] driver.amd64-linux
host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc )
OSX 10.11.5
Steps to reproduce the behavior
I’m not entirely sure how to reproduce the behavior; it may have something to do with putting the computer to sleep for some time and waking it up later.
Inside an Alpine Linux container (FROM ruby:2.3-alpine in my case), look at the time
Put laptop to sleep for 12+ hours?
Wake up laptop and look at the time
In my case, it showed the time as 2016-06-23 22:15:52 -0400, and it should have been 2016-06-24 13:15:53 -0400.
NOTE: I was able to solve this by restarting the Docker beta.
Yes, the delay seems to coincide with time asleep, which makes me think the bhyve host clock stops when asleep. It should be easy to fix by putting ntpd on the xhyve host, and synchronizing with an ntpd instance on the Mac (or just tweaking the xhyve clock to use the Mac’s clock). In any case, it’s very annoying and needs to be fixed.
Time is not only out of sync inside containers.
When I build an image with docker having been started yesterday (and my laptop being suspended over night) the output of docker images tells me the image has been created 16 hours ago, even though I created it just a minute ago.
When I try to push such an image to AWS elastic container registry, there is extremely slow transmission speed.
As others already mentioned restarting docker through the tray icon resolves these issues.
To solve this issue I have created a project that will update the time whenever Mac wakes up from sleep.
It basically listens to the wake up event and execute a shell script whenever a wake up happens.