Dockerfile和docker-compose.yml设置时区
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai'>/etc/timezone
使用RUN命令设置时区。
二、docker-compose.yaml中配置时区
environment:
- SET_CONTAINER_TIMEZONE=true
- CONTAINER_TIMEZONE=Asia/Shanghai
#或者这样写
environment:
SET_CONTAINER_TIMEZONE: true
CONTAINER_TIMEZONE: Asia/Shanghai
environment:
- TZ=Asia/Shanghai
#或者这样写
environment:
TZ: Asia/Shanghai