Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

Docker Timezone Challenges

Daniel Nashed  23 April 2019 21: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

Archives


  • [IBM Lotus Domino]
  • [Domino on Linux]
  • [Nash!Com]
  • [Daniel Nashed]