I try to run a Docker container with the same timezone as my Docker host. The host timezone is CEST
.
When I run :
$ date
Thu Apr 16 11:04:11 CEST 2020
$ docker run -e TZ=CEST debian:buster date
Thu Apr 16 09:04:14 CEST 2020
The container is 2 hours behind the host.
On the other hand, if I set TZ=Europe/Paris
, it works as expected :
$ docker run -e TZ=Europe/Paris debian:buster date
Thu Apr 16 11:04:22 CEST 2020
Is this a bug or am I missing something?
The timezone is set by default and you need to change it manually.
There are some options:
Set it in the Dockerfile:
Using volumes to synchronize with your host:
or
Finally, set it manually but if you restart the container you lose the configuration:
After some research, it appears that
CEST
is not a valid value forTZ
environment variable.CEST
is just a displayable version ofCET
when the current date is summer.In fact, if I set
TZ
to an obviously invalid value, it gives :Also note that it has nothing to do with Docker.
References :