I run a dockerized Spring Boot Application on a Raspberry Pi Zero (yes…that’s possible). It records the current temperatures to a MariaDB (which is running on another RPi). At some point I noticed that the time stamps in the database had a time difference of exactly minus two hours. However, the docker host had the correct time zone (CEST, Europe/Berlin). The running Docker Container had the UTC timezone, though:
$ docker exec 9106cb56b3f6 date
Thu Apr 4 20:00:00 UTC 2020
On the docker host, it was already 22:00h, but the timezone was different.
$ date
Thu Apr 4 22:00:00 CEST 2020
This is where the time difference came from. The solution (for me) was to set the TZ environment variable to the correct timezone “Europe/Berlin” when building the docker image with the Maven Jib plugin:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.7.0</version>
<configuration>
(...stuff omitted for brevity...)
<container>
<environment>
<TZ>Europe/Berlin</TZ>
</environment>
</container>
</configuration>
</plugin>