Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
improved formatting
Source Link
Dan Cornilescu
  • 6.8k
  • 2
  • 19
  • 44

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

[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

[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?

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?

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?

Source Link
lakshayk
  • 636
  • 1
  • 4
  • 8

Incorrect timezoneID inside docker container

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?