docker alpine java设置时区

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

一、环境

宿主机: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

如果文章对您有用,扫一下支付宝的红包,不胜感激!

欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)



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