Jenkins in docker – how to change the time zone


Question:

  • How do I set the time zone in jenkins in a docker container so that when I restart the server I will retain the configuration?

So I'm running RHEL 7 on AWS with docker and jenkins (https://hub.docker.com/r/jenkinsci/blueocean/).

This article talks about how to change the time zone.
https://wiki.jenkins.io/display/JENKINS/Change+time+zone

essentially two ways

  1. run System.setProperty (& # 39; org.apache.commons.jelly.tags.fmt.timeZone & # 39 ;, America / New_York & # 39;) in the script console that works, but if you restart the server or jenkins works again
  2. add it to / etc / sysconfig / jenkins, unfortunately that directory does not exist since it is running in a container

However, I created a volume in

docker window executed -d -p 8080: 8080 -v $ PWD / jenkins: / var / jenkins_home: z -t jenkinsci / blueocean 

this makes the home directory "jenkins-blue"

the directory listing is

4 -rw-r - r--. one   1647 February 27 17:00 config.xml
4 -rw-r - r--. one   3982 February 27 16:57 copy_reference_file.log
4 -rw-r - r--. one    966 February 27 17:04 credentials.xml
0 drwxr-xr-x. 3     16 February 27 17:06 fingerprints
4 -rw-r - r--. one    156 February 27 16:57 hudson.model.UpdateCenter.xml
4 -rw-r - r--. one   1230 February 27 17:07 hudson.plugins.emailext.ExtendedEmailPublisher.xml
4 -rw-r - r--. one    370 February 27 16:58 hudson.plugins.git.GitTool.xml
4 -rw -------. one   1712 February 27 16:57 identity.key.enc
0 drwxr-xr-x. two     41 February 27 16:57 init.groovy.d
4 -rw-r - r--. one     94 February 27 16:58 jenkins.CLI.xml
4 -rw-r - r--. one      7 February 27 17:00 jenkins.install.InstallUtil.lastExecVersion
4 -rw-r - r--. one      7 February 27 5:00 PM jenkins.install.UpgradeWizard.state
4 -rw-r - r--. one    183 February 27 17:00 jenkins.model.JenkinsLocationConfiguration.xml
4 -rw-r - r--. one    171 February 27 16:57 jenkins.telemetry.Correlator.xml
0 drwxr-xr-x. 3     18 February 27 17:00 jobs
0 drwxr-xr-x. 4     37 February 27 16:58 records
4 -rw-r - r--. one    907 Feb 27 16:58 nodeMonitors.xml
0 drwxr-xr-x. two      6 February 27 16:58 nodes
20 drwxr-xr-x. 106  16384 February 27 16:59 plugins
4 -rw-r - r--. one    129 February 28 17:35 queue.xml
4 -rw-r - r--. one     64 February 27 16:57 secret.key
0 -rw-r - r--. one      0 February 27 16:57 secret.key.not-so-secret
4 drwx ------. 4   4096 February 27 17:14 secrets
0 drwxr-xr-x. two    182 February 27 16:59 updates
0 drwxr-xr-x. two     24 February 27 16:58 userContent
0 drwxr-xr-x. 3     Feb. 57 27 17:00 users.
4 drwxr-xr-x. eleven   4096 February 27 16:57 war
0 drwxr-xr-x. two      6 February 27 16:58 workflow-libs
0 drwxr-xr-x. 4     34 February 27 17:06 workspace