RUN apk update && apk add tzdata
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
RUN apk update && apk add tzdata
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
如果想在启动容器时指定时区,可以挂载本地的时区文件
-v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone
参考: https://blog.csdn.net/cljdsc/article/details/117266636