--tz flag vs bind-mounting /etc/localtime for reproducible container timestamps
0 reputation · 24 Apr 2025, 10:28 UTC
Goal is reproducible log timestamps for containers deployed on hosts in different regions. Podman does not perform application-level date conversion; time inside a container follows the container OS clock and its own timezone configuration.
Two documented approaches exist for setting the zone. The --tz flag configures /etc/timezone and TZ inside the container at run time without modifying the image. Bind-mounting host /etc/localtime and /etc/timezone read-only makes the container follow the host zone.
The trade-off centers on portability versus host coupling. An explicit per-container zone is independent of host, while bind-mount couples behavior to the host and changes if the host TZ changes. Podman does not define a default timezone inheritance policy, so containers may start with image defaults or UTC when tzdata is missing.
Which approach preserves consistent timestamps across regions when hosts have different system zones? Is there a defined default inheritance when neither method is used? What is the expected behavior when tzdata is absent and a zone is requested?