Docker容器会自动与其主机同步时间吗? [英] Will a docker container auto sync time with its host machine?

查看:92
本文介绍了Docker容器会自动与其主机同步时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否需要在Docker容器内使用NTP服务器来定期同步时间,或者该容器将与其主机重新同步时间?docker容器的时区设置正确.

Do I need a NTP server inside a docker container to periodically sync the time or will the container re-sync time with its host machine? The docker container time zone is correctly set.

推荐答案

如果您正在OSX上运行boot2docker,请参见以下问题: https://github.com/boot2docker/boot2docker/issues/290

If you are on OSX running boot2docker, see this issue: https://github.com/boot2docker/boot2docker/issues/290

时间同步成为一个问题,因为boot2docker主机在OS睡眠时会发生时间漂移.无法通过在 -v/etc/localtime:/etc/localtime:ro

Time synch becomes an issue because the boot2docker host has its time drift while your OS is asleep. Time synch with your docker container cannot be resolved by running your container with -v /etc/localtime:/etc/localtime:ro

相反,现在,您必须定期在OSX上运行它:

Instead, for now, you have to periodically run this on OSX:

/usr/local/bin/boot2docker ssh sudo ntpclient -s -h pool.ntp.org

Kitematic用户的更新

如果您正在运行 Kitematic (现在是在OSX中启动并在Docker上运行的建议机制),则必须定期运行该命令:

If you are running Kitematic, which is now the suggested mechanism for getting up and running on Docker in OSX, you will have to periodically run this command:

docker-machine ssh default 'sudo ntpclient -s -h pool.ntp.org'

或者,对于旧版本的Docker

Or, for older versions of docker

docker-machine ssh dev 'sudo ntpclient -s -h pool.ntp.org'

针对适用于OSX的新本地Docker用户的更新

新的Docker Beta不再使用VirtualBox和Docker Machine.最新版本的docker(当前为1.12.1-beta25(版本:11807))似乎具有检测时间不连续的时间并进行相应调整的能力.因此,这不再是问题...万岁!

The new Docker Beta does away with VirtualBox and Docker Machine. The latest builds of docker (currently, 1.12.1-beta25 (build: 11807)) seem to have the ability to detect when there has been a time discontinuity and adjust accordingly. Thus, this should no longer be an issue...hooray!!

这篇关于Docker容器会自动与其主机同步时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆