Version 1 (modified by jazz, 7 years ago) (diff) |
---|
2018-02-06
docker
- docker timezone 設定
[CASE 1] 在原本 Host OS 的 Time Zone 是 UTC/GMT 的環境上
~$ date; docker run --rm alpine date; docker run --rm -e TZ=Asia/Taipei alpine date; docker run --rm debian date; docker run --rm -e TZ=Asia/Taipei debian date; docker run --rm centos date; docker run --rm -e TZ=Asia/Taipei centos date Tue Feb 6 06:36:36 UTC 2018 Tue Feb 6 06:36:36 UTC 2018 Tue Feb 6 06:36:37 GMT 2018 Tue Feb 6 06:36:37 UTC 2018 Tue Feb 6 14:36:38 CST 2018 Tue Feb 6 06:36:38 UTC 2018 Tue Feb 6 14:36:38 CST 2018
[CASE 1] 在原本 Host OS 的 Time Zone 是 Asia/Taipei?(GMT+8) 的環境上
~]$ date; docker run --rm alpine date; docker run --rm -e TZ=Asia/Taipei alpine date; docker run --rm debian date; docker run --rm -e TZ=Asia/Taipei debian date; docker run --rm centos date; docker run --rm -e TZ=Asia/Taipei centos date 二 2月 6 14:40:42 CST 2018 Tue Feb 6 06:40:43 UTC 2018 Tue Feb 6 06:40:43 GMT 2018 Tue Feb 6 06:40:44 UTC 2018 Tue Feb 6 14:40:44 CST 2018 Tue Feb 6 06:40:44 UTC 2018 Tue Feb 6 14:40:45 CST 2018
- 參考 https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
- 看起來 debian 跟 centos 都可以直接透過設定 {{TZ}} 環境變數解決,但是 alpine 的 base image 就不能使用環境變數來解決