Setting TZ on Linux docker container

Hello all,

I'm wondering if it's possible to set the timezone on an already configured server running in docker? I've tried stopping & re-starting the server with "docker run -e TZ=America/Chicago ... fancybits/channels-dvr:tve" but it still uses UTC. Is it possible to use local time in this configuration?

If you are passing the correct environment and it still does not recognize it, then there is something else going on. (Is your server hosting the container properly configured with the correct TZ? What host OS are you using?)

To answer your question, I do not believe you can change the TZ within the container and relaunch the server process to pick up the new TZ while keeping the container active.

More details are always good, as you have provided very few.

I'm running docker engine on Debian bookworm. No compose, desktop or any addons -- just the docker engine. It turns out there was a typo in my startup script. Correcting the typo and re-starting the container fixed the problem. The server is now using the correct time zone.

Interestingly enough, the guide data for my local channel lineup has the correct UTC offset, so setting a TZ doesn't matter all that much. The guide displays properly and season passes record at the appropriate time. I was running this server for about a week before I realized things were off.
Late night 'On Later' entries were appearing in the 'tomorrow' section and creating advanced passes by matching times resulted in empty schedules.

In any case all is well now.

All time/date information is saved UTC; setting the timezone is simply to allow it to present properly so times/dates align with your expectations.

TZ affects the server's definition of "primetime" which is used in On Later, as noted by OP

An alternative way is to set it to the host's setting via volume mounts:

volumes:
  - /etc/localtime:/etc/localtime:ro
  - /etc/timezone:/etc/timezone:ro
3 Likes

I like this solution best. Thank you.

I copied the command verbatim from here. Perhaps another bullet point explaining TZ options would be beneficial to beginners (like me).

Thanks again!

1 Like

That assumes those files exists on the host and the content is in the correct format.