I’m surprised there seems to be no easy and cross-platform way to synchronize the timezone from host to container at runtime. So, the timezone in the container should not be set when it’s built but when it’s started. So far I found the following two options:
docker run -v /etc/timezone:/etc/timezone:ro
docker run -e "TZ=Asia/Kolkata"
Both are a no-go for my use case. a) works only on Linux as there’s no
/etc/timezone on Windows and macOS. b) requires the user to manually set the desired timezone (i.e. the same as on the host).
Are these really all sensible options?
For the sake of completeness doing this at build time in the
Dockerfile you’d use something like this I learned:
RUN sudo echo "America/New_York" > /etc/timezone RUN sudo dpkg-reconfigure -f noninteractive tzdata