Docker Community Forums

Share and learn in the Docker community.

Time clarification

Hi, I want to make sure that I understand how timezones work with Docker. Is it correct to say that configuring environment variable TZ=<locale>, such as TZ=UTC, is sufficient to apply a consistent timezone across the entire container, including any child processes and subsystems?

Does TZ work for:

  • Dockerfile’s?
  • docker run?
  • docker-compose?
  • Kubernetes?
  • Vagrant?
  • LXC, LXD?

Does this same process work for Windows images such as the Microsoft nano images? BSD containers?

Is there a special locale value for indicating that a container should match the host’s timezone? Or would that have to be manually applied?

How do OS-less containers behave, such as FROM scratch containers with statically linked binaries? Correct to say that those would match the host’s timezone by default, and that TZ=<locale> is sufficient to configure timezones for these kinds of containers as well?

Could we document the recommended procedure for customizing timezone in the main Docker manual? So far, I’ve only found scattered posts around Stack Overflow and Medium.

Do the library/ namespace images have consistent timezone behavior? E.g., are they all set to UTC, or perhaps EST, or perhaps all match the host timezone?

What gives you the impression that updating the timezone by setting the TZ environment variable is a docker feature?

Actualy the os package tzdata needs to be installed in the image and an entrypoint script needs to take care of using the TZ variable to update the time zome configuration inside a running container.

I would be surprised if tzdata is available for windows as well.