Answers: <p>The case is <code>dpkg-reconfigure tzdata</code> simply creates <code>/etc/localtime</code> as a copy, hardlink or symlink (a symlink is preferred) to a file in <code>/usr/share/zoneinfo</code>. So it is possible to do this entirely from your <code>Dockerfile</code>. Consider:</p>
  
  <pre><code>ENV TZ=Asia/Kolkata
  RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &amp;&amp; echo $TZ &gt; /etc/timezone
  </code></pre>
  
  <p>And as a bonus, <code>TZ</code> will be set correctly in the container as well.</p>
  
  <p>This is also distribution-agnostic, so it works with pretty much anything Linux.</p>
  
  <p>The original answer: <a href="https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes">https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes</a></p>
  
Answers: CC BY-SA 3.0
Answers: 2017-08-02T03:51:58.820Z
Answers: This is a copied answer from stackoverflow. Please mention the source of answers when youre copying it to give due credit to the original posters. Anyways, i have already created a symlink and it just doesnt get te timezone ID right.
Answers: lakshayk
Answers: CC BY-SA 3.0
Answers: 2017-08-02T02:01:22.387Z
Answers: 2017-08-02T04:35:13.420Z
Answers: 2017-08-02T04:35:13.420Z
Answers: Wissam Roujoulah
Body: <p>I have created a docker image from the base Centos7 image and while running the container from it, the time and timezone were not in sync with my host. To give the container the same timezone as that of the host. I mounted /etc/timezone and /etc/localtime from the host to the container using the '-v' argument while running the container. After running the container with this, this is what i get inside the container and host:</p>
  
  <p>For docker container running timedatectl: </p>
  
  <blockquote>
    <p>[root@d7a24c723f6a /]# timedatectl Local time: Tue 2017-08-01 10:28:30
    IST Universal time: Tue 2017-08-01 04:58:30 UTC RTC time: n/a Time
    zone: UTC (IST, +0530) NTP enabled: n/a NTP synchronized: no RTC in
    local TZ: no</p>
  </blockquote>
  
  <p>For host running timedatectl: </p>
  
  <blockquote>
    <p>[root@indiadev72 ~]# timedatectl Local time: Tue 2017-08-01 10:27:29
    IST Universal time: Tue 2017-08-01 04:57:29 UTC RTC time: Tue
    2017-08-01 04:57:29 Time zone: Asia/Kolkata (IST, +0530) NTP enabled:
    yes NTP synchronized: no RTC in local TZ: no DST active: n/a</p>
  </blockquote>
  
  <p>I am not sure why my docker container is not able to take the timezone of the host.</p>
  
  <p>EDIT: Also while running some of my test cases, i am able to see that the application is reading timezoneid as 'GMT+530' instead of Asia/Kolkata. While GMT+530 is indeed Asia/Kolkata but due the timezone ID mismatch inside the container my test cases are failing. Maybe its just the timezoneID issue and the container is picking up the correct time. Can someone please help here?</p>
  
Tags: <docker><linux>
Title: Incorrect timezoneID inside docker container
UserDisplayName: lakshayk
ThreadText: # Incorrect timezoneID inside docker container
  
  (Asked by: username_0 on 2017-08-01)
  
  I have created a docker image from the base Centos7 image and while running the container from it, the time and timezone were not in sync with my host. To give the container the same timezone as that of the host. I mounted /etc/timezone and /etc/localtime from the host to the container using the '-v' argument while running the container. After running the container with this, this is what i get inside the container and host:
  
  For docker container running timedatectl:
  
  > [root@d7a24c723f6a /]# timedatectl Local time: Tue 2017-08-01 10:28:30
  > IST Universal time: Tue 2017-08-01 04:58:30 UTC RTC time: n/a Time
  > zone: UTC (IST, +0530) NTP enabled: n/a NTP synchronized: no RTC in
  > local TZ: no
  
  For host running timedatectl:
  
  > [root@indiadev72 ~]# timedatectl Local time: Tue 2017-08-01 10:27:29
  > IST Universal time: Tue 2017-08-01 04:57:29 UTC RTC time: Tue
  > 2017-08-01 04:57:29 Time zone: Asia/Kolkata (IST, +0530) NTP enabled:
  > yes NTP synchronized: no RTC in local TZ: no DST active: n/a
  
  I am not sure why my docker container is not able to take the timezone of the host.
  
  EDIT: Also while running some of my test cases, i am able to see that the application is reading timezoneid as 'GMT+530' instead of Asia/Kolkata. While GMT+530 is indeed Asia/Kolkata but due the timezone ID mismatch inside the container my test cases are failing. Maybe its just the timezoneID issue and the container is picking up the correct time. Can someone please help here?
  
  **Tags:** docker, linux
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-02. Score: 1
  
  The case is `dpkg-reconfigure tzdata` simply creates `/etc/localtime` as a copy, hardlink or symlink (a symlink is preferred) to a file in `/usr/share/zoneinfo`. So it is possible to do this entirely from your `Dockerfile`. Consider:
  
  ```
  ENV TZ=Asia/Kolkata
  RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
  
  ```
  
  And as a bonus, `TZ` will be set correctly in the container as well.
  
  This is also distribution-agnostic, so it works with pretty much anything Linux.
  
  The original answer: <https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes>
  
  > **Comments:**
  > **username_0**: This is a copied answer from stackoverflow. Please mention the source of answers when youre copying it to give due credit to the original posters. Anyways, i have already created a symlink and it just doesnt get te timezone ID right.  
  
  ---
  
  