← Notes

December 17, 2020

Set up tzdata in a Docker container

How to set up the timezone in Docker containers.


Tags: docker tzdata timezone

After installing tzdata the configuration process starts up with the following prompt:

Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area:

This is fine when installing on a regular system, but not when using Docker. In order to configure tzdata without showing the configuration prompt it is sufficient to set the following environment variables in the Dockerfile.

ENV TZ=Europe/London

You can find here the list of timezones.