Will docker container auto sync time with the host machine?

前端 未结 7 1980
长情又很酷
长情又很酷 2020-11-28 18:43

Giving I already changed the timezone of docker container correctly. Do I need to install a NTP server inside the docker container to periodically sync the time or the conta

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 19:24

    The current solution for osx time drift on docker (April 2018):

    I do have my mac on an NTP server, but this fixed clock drift with containers:

    From https://docs.docker.com/docker-for-mac/troubleshoot/#known-issues :

    If your system does not have access to an NTP server, then after a hibernate the time seen by Docker for Mac may be considerably out of sync with the host. Furthermore, the time may slowly drift out of sync during use. To manually reset the time after hibernation, run:

    docker run --rm --privileged alpine hwclock -s
    

    Or, to resolve both issues, you can add the local clock as a low-priority (high stratum) fallback NTP time source for the host. To do this, edit the host’s /etc/ntp-restrict.conf to add:

    server 127.127.1.1              # LCL, local clock
    fudge  127.127.1.1 stratum 12   # increase stratum
    

    Then restart the NTP service with:

    sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist
    sudo launchctl load /System/Library/LaunchDaemons/org.ntp.ntpd.plist
    

提交回复
热议问题