openHAB running in Docker - system time is one hour behind


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?

Thanks for your help!

Ok, found a potential solution in another thread, when setting:


for the container, then the time is correct, in the logs, in Karaf and also with time.toZDT().

However, ist this the proper way of setting the time zone? What could be the reason for setting the time zone on the UI not being sufficient?

There are four places where the timezone is set and takes effect. Each has a different scope and use.

  1. The host operating system. Obviously most things will pick up the timezone from there.

  2. 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.

  3. 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.

  4. 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?

1 Like

Thanks for the explanation, then the Java options seem to be the way to go.

Actually I could not find any place where the OH regional setting as applied, the time was incorrect, everywhere I checked.

I raised an issue for that:

This solved also my issue here…my rules where always late but I configured the time on my host system correctly.

It is used by bindings when handling date & time, but not all.