在Docker容器中更改系统日期时间,而不影响主机 [英] Change system date time in docker containers without impacting the host

查看:1487
本文介绍了在Docker容器中更改系统日期时间,而不影响主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可能在Docker容器中更改系统时间,而不会更改主机本身。我们正在使用码头集装箱进行测试,这些容器有时是时间敏感的。我注意到,对主机时间的任何更改都会立即反映到docker容器(这是有道理的,因为它们使用相同的内核)。但是我希望Docker为您提供一种方法,以某种方式覆盖容器的开始时间并从中移出。

I was wondering if its possible to change the system time in Docker containers without changing the host itself. We are using docker containers for testing which are sometimes time sensitive. I notice that any changes made to the host time are reflected to the docker containers right away (which makes sense since they are using the same kernel). I am hoping however that Docker provides a way for you to somehow override the start time of the container and move from thereon.

谢谢

推荐答案

只是对于那些希望在docker容器中有不同的datetime的跟踪, https://github.com/wolfcw/libfaketime 应该可以做这个工作。

Just a follow up for those looking to have different datetime in docker containers, https://github.com/wolfcw/libfaketime should probably be able to do the job.

谢谢

这篇关于在Docker容器中更改系统日期时间,而不影响主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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