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

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

问题描述

是否可以在不更改主机本身的情况下更改Docker容器中的系统时间?

Is it possible to change the system time in Docker containers without changing the host itself?

我们正在使用Docker容器进行测试,这些容器有时对时间敏感。我注意到,对主机时间所做的任何更改都会立即反映到Docker容器中(这很有意义,因为它们使用的是同一内核)。但是,我希望Docker为您提供一种以某种方式覆盖容器的开始时间并从其开始移动的方法。

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容器中具有不同日期时间的人来说,只是一个后续, 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天全站免登陆