docker設定container時區 - jenhaoyang/backend_blog GitHub Wiki

解法1:
https://www.cloudsavvyit.com/12859/how-to-handle-timezones-in-docker-containers/

FROM ubuntu:latest
ENV TZ=Europe/London
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata

啟動時:

docker run -e TZ=Europe/London -it ubuntu:latest

或者跟本機時間同步

docker run -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -it ubuntu:latest

解法2:
RUN apt-get update
&& DEBIAN_FRONTEND=noninteractive apt-get install tzdata
&& apt-get autoremove -y
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*

###change time zone ENV TZ=Asia/Taipei RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
&& echo $TZ > /etc/timezone
&& dpkg-reconfigure --frontend noninteractive tzdata

參考:
https://www.cloudsavvyit.com/12859/how-to-handle-timezones-in-docker-containers/
https://www.ivankrizsan.se/2015/10/31/time-in-docker-containers/