Unable to set Timezone in Docker Container

2.2.0p14 RAW
Ubuntu 22.04 W/ Docker

No matter what I do, I can’t seem to get my instance off UTC timezone. We’re CST, but all notifications, logs, etc show UTC. Tired of adding 6.

I’ve done the following:

  • Mounted /etc/timezone to the container as RO
  • Mounted /etc/localtime to the container as RO.
  • Confirmed docker host is using CST timezone.
  • Passed the TZ=America\Chicago timezone to the container
  • Shelled into the container, ran date, and it shows CST
  • REbooted the host, the container, all of it after this. Been going on for multiple versions.

For clarification, our Notifications and the “Server TIme” widget on the main page keep showing UTC.

You can set TZ in the site’s ~/etc/environment config file.

Correct. the TZ is set there already, and lists CST.

Originally when you said that the date was actually correct inside the container what ultimately did this? (before you rebooted everything and it reset again)

mounting /etc/localtime and /etc/timezone to the container, then going into the container in an interactive session and running ‘date’ shows the correct timezone.

Still the checkmk web interface is showing UTC.

So I tested it as my checkmk instance is in a container using kubernetes and was using UTC as well. I went ahead and had a configmap made from the /usr/share/zoneinfo/America/Chicago and mounted it as /etc/localtime and this immediately resolved after a container restart.

You could try something similar in docker for example:

/usr/share/zoneinfo/America/Chicago:/etc/localtime:ro (i believe that’s the method for a readonly mount in docker)