How to set SonarQube TimeZone in a Docker container setup

I’m trying to update the Time that SonarQube uses inside of a Docker container. It is 2 hours ahead of where I need it to be:

  • SQ version with a Postgres back end
  • I need to set the Timezone to be Central US time
  • Inside of the container I have tried setting the date manually, but that is not allowed. All other solutions I have used in the past are not available in this container without major updates to install other features.
  • The host machine’s time is set to Central time as desired. It’s just inside the SonarQube Docker container where the system time is 2 hours ahead of the desired time
  • I have also searched through the docs and yet to find anything that specifies where I can set the time inside of the app

Any other suggestions?

Hey there.

Not currently being able to run SonarQube on Docker (because I’m using an M1 mac), I would anticipate that you could just do something like docker run -e TZ="CET" sonarqube.

Although as far as I’m aware – users don’t typically need to do this. What are the symptoms of your SonarQube server’s time not aligning with your local time? What do you see in the UI – what features are behaving oddly?

My apologies for delayed response. The issue is that everything is being saved as GMT, and I need it to be saved as Central US time.

When I look at the Administration > System > “Web JVM Properties” I see that user.timezone is set to GMT.

Would it be possible to somehow update that value to be set to US Central Timezone?

For the record, I have tried setting ‘user.timezone’ inside of the existing Docker container in the, but it does not seem to be enforced in the app.

container:/opt/sonarqube/conf $ cat

Then in the sonar.log file I see that the user.timezone parm is sent to the JVM:

container:/opt/sonarqube/logs $ cat sonar.log | grep timezone
2022.09.23 01:48:36 INFO app[o.s.a.ProcessLauncherImpl] Launch process[COMPUTE_ENGINE] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjdk/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/ -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Duser.timezone=America/Chicago -Dhttp.nonProxyHosts=localhost|127.|[::1] -cp ./lib/sonar-application- /opt/sonarqube/temp/sq-process7023462536063294818properties
2022.09.23 20:41:37 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[COMPUTE_ENGINE] from [/opt/sonarqube]: /usr/lib/jvm/java-11-openjdk/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/ -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Duser.timezone=CET -Dhttp.nonProxyHosts=localhost|127.
|[::1] -cp ./lib/sonar-application- /opt/sonarqube/temp/sq-process1794718339891702569properties

I have this container setup the way I want it for our POC, and I do not have external volumes (unfortunately), and at this point I’d rather not have to start from scratch.