Docker Timezone Challenges
Daniel Nashed – 23 April 2019 19:02:12
When working on the Traveler for Docker support I ran into an issue. The Traveler server complained about a timezone difference between the Domino server and the JVM used by Traveler.
I assumed that the timezone recommendations in the Docker technote would be sufficient
https://www.ibm.com/support/docview.wss?uid=swg22013200
But it turned out that they are not working correctly -- at least in the current Docker and CentOS releases.
The idea was to map the Docker host /etc/localtime to the Docker container.
-v /etc/localtime:/etc/localtime
But it turned out that the mount does not work and the Docker container was still pointing to /usr/share/zoneinfo/UTC.
The solution is to pass the wanted timezone to the Docker image during build as a build argument.
The Domino on Docker does now by default read the host settings and pass it to the build process.
And there is also build script option to specify it manually.
There will be also an option to pass the timezone in the run statement and have it changed by the entry point script.
-- Daniel
Reading the timezone could be implemented like this
DOCKER_TZ=$(readlink /etc/localtime | awk -F'/usr/share/zoneinfo/' '{print $2}')
echo "[$DOCKER_TZ]"
And here is the logic that can be used check and update the timezone.
This might be also useful for other Docker projects.
set_timezone ()
{
if [ -z "$DOCKER_TZ" ]; then
return 0
fi
CURRENT_TZ=$(readlink /etc/localtime)
SET_TZ=/usr/share/zoneinfo/$DOCKER_TZ
if [ "$CURRENT_TZ" = "$SET_TZ" ]; then
echo "Timezone [$DOCKER_TZ] already set"
return 0
fi
if [ ! -e "$SET_TZ" ]; then
echo "Cannot read timezone [$SET_TZ] -- Timezone not changed"
return 1
fi
echo "Timezone set to [$DOCKER_TZ]"
ln -sf "$SET_TZ" /etc/localtime
return 0
}
DOCKER_TZ=Europe/Berlin
set_timezone
- Comments [1]
1MiWi 23.01.2023 14:43:20 Docker Timezone Challenges
It's sufficient to add the Timezone parameter to your .env
TZ=Europe/Paris
docker container run --name traveler --restart=always -it -v /local/notesdata:/local/notesdata --env-file .env --hostname yourhostname.de -p 1352:1352 -p 443:443 -p 80:80 -p 8080:8080 -p 50125:50125 -p 50126:50126 imageID
Afterwards your domino live will display the correct time again. If TZ is unset, the /etc/localtime will be used instead, which generates problems. The TZ need to be set from build/run command on.