How to set timezone in Docker Container

相信大家在部屬Container後才發現時區怎麼跟系統的不一樣,我在設定MeterSphere的Mysql時區後,重啟服務發現時區又變回去了,所以用了其他方法才解決。

原方法

echo "Asia/Taipei" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata

然後發現時區還是沒變!?

後來爬了一下Stackoverflow,這就有效了,我所在地是Asia/Tapei。

dpkg-reconfigure tzdata
Geographic area: 6
Time zone: 73

設定完後就會顯示當前時間了。

雖然時區已改,但服務可能沒跟著,記得重啟Container唷!

參考資料:

https://stackoverflow.com/questions/24551592/how-to-make-sure-dockers-time-syncs-with-that-of-the-host

--

--

NTUT CSIE | Biomedical Informatics Lab | github.com/stwater20 | sectools.tw

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store