Binding /etc/localtime maybe more convenience for TimeZone setting

Hi teams,
Much thanks to provide such great docker images.

I found that most container settings all have -e TZ=Europe/London.
Is it possible to support read timezone from /etc/localtime for Linux platform ?
To support this, we can just use -v /etc/localtime:/etc/localtime:ro to assign the localtime with Timezone.


yes, it works fine in most cases, though you’ll likely still want to pass the TZ variable.

It is a very convenient way to configure the timezone, but it has a big downside:
It is only working on Linux hosts. Even macOS hosts, which are unix based, do not support this mechanism because /etc/timezone is not accessible.

I prefer to pass the TZ variable and use this mechanism in my own image.

After digging deeper: It is not a neither nor…

If -e TZ="…" is working, you can switch to -v /etc/localtime: … without any modification of the image.

You test this with my test container



hi, yes, you can use both as I already stated… passing /etc/localtime will not ALWAYS work, which is why i suggested doing both.

In which cases does it not work (except being on the wrong host)?

BTW: Doing both will result in error messages on hosts not supporting binding /etc/localtime .

By checking the log of the container with the timestamp, some container will display correct time with my local time, but some container still just display the UTC+0 time.