How to modify time zone in jenkins in docker

I started a jenkins project in k8s, and the image uses the official docker image

image: jenkins

During use, it was found that the time zone of jenkins was incorrect, and the 0 time zone was used.

Then I found a lot of ways on the Internet, thinking that it can be solved by passing environment variables, but it is not feasible.

Finally, I downloaded the Dockerfile of the official image to rebuild, and added the following two lines to the Dockerfile before building to solve

RUN rm -rf /etc/localtime && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN echo 'Asia/Shanghai' > /etc/timezone

 

In fact, the bottom line is that the official image of jenkins uses openjdk, and then openjdk does not read the time zone of the operating system by default, but reads the time zone settings of the file /etc/timezone.

/etc/localtime is to set the time zone of the operating system. If these two are unified into the East Eighth District, Asia Shanghai, there is no problem.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326161298&siteId=291194637