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

查看:26
本文介绍了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 主机会发生时间漂移.使用 -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天全站免登陆