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

Docker time outof sync with osx host #1260

Closed
snimavat opened this issue Feb 5, 2017 · 12 comments
Closed

Docker time outof sync with osx host #1260

snimavat opened this issue Feb 5, 2017 · 12 comments

Comments

@snimavat
Copy link

snimavat commented Feb 5, 2017

My osx system has IST time zone.
When i run, docker info command, it shows a wrong system time which is few hours behind the osx host. docker info shows UTC time.

I have properly configured time/timezone on my osx host... my osx dint sleep, i am actively working on my mac

Docker info shows
System Time: 2017-02-05T08:01:45.995094136Z

date command on osx shows
un Feb 5 13:32:31 IST 2017

Restarting docker does not help either

Expected behavior

Docker would have same time/time zone as osx host

Actual behavior

Docker time is different then osx host

Information

Docker for Mac: version: 1.13.0 (0c6d765c5)
macOS: version 10.11.5 (build: 15F34)
logs: /tmp/76AEDBF3-6D1A-4483-A341-F90F0E69876C/20170205-133012.tar.gz
[OK] vmnetd
[OK] dns
[OK] driver.amd64-linux
[OK] virtualization VT-X
[OK] app
[OK] moby
[OK] system
[OK] moby-syslog
[OK] db
[OK] env
[OK] virtualization kern.hv_support
[OK] slirp
[OK] osxfs
[OK] moby-console
[OK] logs
[OK] docker-cli
[OK] menubar
[OK] disk

@marcelmfs
Copy link

Not a bug, it's a feature of the xhyve VM used as docker machine on osx (it's UTC by default)

@kinghuang
Copy link

@marcelmfs The timezone isn't the actual issue here. The time inside the the vm on Docker for Mac drifts away from system time. If you normalize the timezone to UTC In @snimavat's example, you can see that it's 08:01:45 in the vm and 08:32:31 on the host.

I have the same problem with my Docker for Mac. At the moment, it's 18:11:37 in the vm, but 18:37:20 on my Mac host. My Docker for Mac VM's been up for 4 days, and the drift increases the longest it's been up.

My Mac:

→  ~ date
Thu  9 Feb 2017 11:37:20 MST

Inside the VM:

/ # date
Thu Feb  9 18:11:37 UTC 2017
/ # uptime
 18:13:11 up 4 days,  2:30,  load average: 0.41, 3.22, 2.99

@kangaechigai
Copy link

Ignoring timezone, this is a partial duplicate of #17, which doesn't have a permanent solution for the time drift, but some comments include this temporary workaround to run after waking from sleep:
docker run --rm --privileged alpine hwclock -s

@ijc
Copy link
Contributor

ijc commented Feb 20, 2017

@snimavat thank you for your report. Unix systems run their system clock in UTC and any appearance of timezones is entirely a userspace concern i.e. by the libc or other application level software, on Linux this is generally configured by /etc/localtime and my Mac seems to have a similar file. In the context of Docker this means that the timezone seen within a container is a function of the user level software within that container. You'll find several closed issues on https://github.com/docker/docker/issues on the subject. So I'm afraid to say that the behaviour you are seeing is by design and unlikely to change. Sorry.

@kinghuang please lets keep this issue for the timezone issue which the original report is concerned about instead of hijacking it to be another dup of #17.

@iMerica
Copy link

iMerica commented Jan 26, 2018

Issue persists in Version 17.12.0-ce-mac47 (21805)

@iMerica
Copy link

iMerica commented Jan 26, 2018

from within a container:

 date '+%Y %m %d %H %M%S' // 2018 01 26 03 2047

from within my mac:

date '+%Y %m %d %H %M%S' // 2018 01 25 22 1907

@kolomeetz
Copy link

Same problem in Version 17.12.0-ce-mac49 (21995)

@KpaBap
Copy link

KpaBap commented Feb 6, 2018

Having the same problem - the time inside and outside of docker is off by ~7 minutes. Why is this closed with a non-answer?

@samsonjs
Copy link

samsonjs commented Feb 7, 2018

Host Mac:

[ 9:22pm] ~/Projects/pronto:master % date
Tue  6 Feb 2018 21:23:52 PST

6 seconds later in the Docker container:

root@cf86647b3ff4:/pronto# date
Tue Feb  6 21:28:58 PST 2018

@thomasst
Copy link

See #2076

@eshork
Copy link

eshork commented Jul 18, 2018

Without some external help, guest VMs on any platform will inevitably drift time from the host. It's a fundamental issue that VMware and Citrix deal with via the agent they highly encourage you install on the guest VM. The answer to this issue is to add a mechanism to sync time sources from host-> guest on a regular basis; either via direct hwclock assignment via crontab on the guest vm, or via a guest vm service solution like ntp/chrony.

However, that explanation doesn't solve this issue for you guys with timing-sensitive docker images. I happen to have this same problem at the moment. So, in the meantime, I put together a super-gross docker image to run chrony on the VM that Docker for Mac utilizes. (https://hub.docker.com/r/eshork/docker-mac-chrony/) It's been working for me, but obviously use at your own risk. Please submit issues to the github issue tracker as you find them; I'll do my best to address them in a timely manner.

My hope is that the Docker for Mac CE build has a legit fix for this issue still landing within Q3/2018. Until then, I sincerely hope my awful hack helps ya'll out a bit...

@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 Jun 22, 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