Change system date time in Docker containers without impacting host

前端 未结 2 536
礼貌的吻别
礼貌的吻别 2020-12-30 03:21

Is it 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 se

相关标签:
2条回答
  • 2020-12-30 04:01

    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.

    0 讨论(0)
  • 2020-12-30 04:13

    Simple:

    Steps:

    1. First check the localtime of the docker container:

      [root@locdb oracle]# zdump /etc/localtime
      /etc/localtime  Tue May 22 13:59:40 2018 UTC
      
    2. Check the timezones like below:

      [root@locdb oracle]# zdump /usr/share/zoneinfo/* | tail -10
      /usr/share/zoneinfo/UTC          Tue May 22 14:01:21 2018 UTC
      /usr/share/zoneinfo/Universal    Tue May 22 14:01:21 2018 UTC
      /usr/share/zoneinfo/W-SU         Tue May 22 17:01:21 2018 MSK
      /usr/share/zoneinfo/WET          Tue May 22 15:01:21 2018 WEST
      /usr/share/zoneinfo/Zulu         Tue May 22 14:01:21 2018 UTC
      /usr/share/zoneinfo/iso3166.tab  Tue May 22 14:01:21 2018
      /usr/share/zoneinfo/posix        Tue May 22 14:01:21 2018
      /usr/share/zoneinfo/posixrules   Tue May 22 10:01:21 2018 EDT
      /usr/share/zoneinfo/right        Tue May 22 14:01:21 2018
      /usr/share/zoneinfo/zone.tab     Tue May 22 14:01:21 2018
      
    3. Copy the one that you need for example :

      cp  /usr/share/zoneinfo/UTC /etc/localtime
      
    0 讨论(0)
提交回复
热议问题