Syncing clock with host

Would it be possible to sync the host’s clock with the VM one?

Host: Thu Apr 28 23:07:55 WEST 2016
VM: Thu Apr 28 22:07:55 UTC 2016

2 Likes

I ran into this as well and it caused some problems. Specifically, I was trying to run rndc (bind command line tool) to update a bind slave and the command returned an error code due to the clock skew.

To work around this, I bumped up the ram I wanted allocated to my xhyve docker machine in the from toolbar -> settings -> advanced, which restarted the xhyve vm and updated the clock.

I’m curious if there is another way to work around the issue.

I find I have this problem too when I wake up my Mac after it was sleeping for a few minutes. This command seems to work (perhaps replace centos:6.7 with ubuntu or a base image you already have - I think any image will work so long as you enter as the root user)

docker run --rm --privileged centos:6.7 date -s “`date`”

(Note the back quotes)

Setting the date/time in any container sets it for the underlying VM, and so all containers see the new time.

Kind of a pain, but it seems to work.

1 Like

Better clock sync was introduced in Beta 13. Do you still need to do this in order to see (semi-)accurate timekeeping?

It’s still the same regarding this particular issue, unless this wasn’t changed at all and timezones must be dealt with separately:

❯ docker run --rm alpine date
Thu May 26 22:11:18 UTC 2016

~
❯ date
Thu May 26 23:11:18 WEST 2016

1 Like

The behavior regarding timezones should be the same as Docker on Linux: the timezone in the container is set to UTC.

Time sync does seem to be much better in beta 13. I have yet to need to run the command above. Thanks! – Adam

I also confirm an improved time syncing in beta 13. Thank you!

running beta 16 here.
With a long postgresql container thats been running over a few suspend resume cycles:
docker exec -it chai-postgres date
Wed Jun 22 01:00:42 UTC 2016
host system date
date
Thu 23 Jun 2016 11:25:29 BST
Restarting docker fixed it but don’t want to have to do that each time

1 Like

Also running beta 16 on el capitan. Myself and everyone else in my shop gets dramatic clock skew after mac sleeping using largely ubuntu 14.04 stock containers.

3 Likes

I see clock skew errors again intermittently after sleep in a centos 6.7 container.

2 Likes

I am having the same issue when my Mac was sleeping. Restarting Docker from the menu bar item temporarily solves the issue.

To test this I use this command:

docker run --rm ubuntu date -u && date -u

appears to be a windows problem too

I’m running the latest beta and just realized I had 6 minutes of clock skew - my AWS api calls were failing from the container.

1 Like

I use Docker for Mac for running builds and testing, this issue makes make very unhappy and timestamps on build artefacts get me very confused at times. Timezone arithmetics are bad enough, clock drift arithmetics are a pure joy!

Yeah this is seriously annoying. On OS X 10.12 after some sleeping the host shows:

% date
Tue Oct 25 10:21:46 MDT 2016

While a random container is showing:

# date
Tue Oct 25 16:04:57 UTC 2016

I’m also seeing significant clock drift in my Alpine containers on OSX 10.12. This should be treated as a serious bug - lots of things depend on the clock being correct!

I just added time syncing to the Mac host on the d4m-nfs project, https://github.com/IFSight/d4m-nfs which is intended to get over the slow file access of Docker for Mac current implementation of osxfs.

Still seeing this with Docker for Mac Version 1.12.3-beta29.3 (13640)

Issue still exists on Docker For Mac Version 1.12.3 (13776)