I am running openHAB in a Docker container on my Synology NAS, a DS420+.
For some reason, the time used by openHAB is one hour behind. I noticed that on several places, the log file entries, the time returned by time.toZDT() in Javascripts and also the last update time of my Shelly H&T sensors is always one hour behind. Also on the Karaf console, “date” shows the time one hour behind.
The time on the NAS is set correctly, and also the time zone in openHAB’s regional setting is set correctly to GMT+1 (Vienna).
How does openHAB running in a Docker container gets its time? What could be the reason for it running an hour behind?
There are four places where the timezone is set and takes effect. Each has a different scope and use.
The host operating system. Obviously most things will pick up the timezone from there.
Since you are running in a container, you cannot count on your host’s operating system matching the container’s. The whole point of containers is to isolate the container from the host. Often one will mount /etc/timezone into the container so that the container picks up the host’s timezone, but Synology is weird and I’m not sure it even has an /etc/timezone.
The JVM has it’s own timezone setting. When not set it will usually pick up the timezone from the host but not always (there are lots of threads on the forum if you want to see some of the cases. By passing the EXTRA_JAVA_OPTS, you are setting the JVM’s timezone. This is going to be used by OH core, logging, etc.
The OH regional setting. I honestly have no idea what the point of that one is. It doesn’t seem to actually change anything but maybe that’s a bug? Maybe it only applies in some areas but not everywhere in OH?