Dockerfile 时区设置
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' >/etc/timezone
EG、
FROM fiadliel/java8-jre VOLUME /tmp ADD api_h5-0.1.jar app.jar RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo 'Asia/Shanghai' >/etc/timezone ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
docker已运行容器里的时区修改 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 或者 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 重启容器即可
# 创建并运行容器,通过 -e TZ="Asia/Shanghai" 设置时区
docker run -e TZ="Asia/Shanghai" -d -p 80:80 --name nginx nginx