docker alpine java设置时区

作者: wencst 分类: docker,JAVA 发布时间: 2017-11-23 10:22 阅读: 1,264 次

一、环境

宿主机:CentOS7

docker镜像:jdk1.7+alpine系统

二、问题

当程序启动时,java程序中获取的时间为UTC时间,那么如何改成ETC时间呢?

三、解决

1.先将系统时间改为ETC时间

#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime (注意,alpine系统中没有自带zoneinfo文件夹,从宿主机系统中拷贝即可)
#echo $TZ > /etc/TZ(部分linux系统中需要)

2.修改java程序读取时间

#echo $TZ > /etc/timezone

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

2 Comments
  • Tim Monte

    June 9, 2018 at 12:13 pm

    Good day! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having difficulty finding one? Thanks a lot!

    1. wencst

      June 19, 2018 at 4:00 pm

      Sorry , I didn’t use this plugin. But I think you can search it in Plugins function. Wish it help!

Leave a Reply

Your email address will not be published. Required fields are marked *

标签云