go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.24k stars 5.5k forks source link

Time zone in docker container is in UTC, even when mounting localtime and timezone files from host #32530

Open user00265 opened 6 days ago

user00265 commented 6 days ago

Description

Looking at published packages in my repository, I noticed that it said "4 hours ago" when it should've been "10 hours ago" in the Gitea web interface. At this point, after looking at dates and times overall I noticed that Gitea was following UTC and not CST/CDT (visually in the interface) even though configured for America/Chicago. While investigating I issued the date command on the console of the docker container showing the time zone in UTC instead of CST as expected, while the host is showing CST as expected.

I verified that both /etc/timezone and /etc/localtime from the host are passed to the container as volumes as suggested in the documentation and their contents are available to the docker container. Both files contain valid data, and the host has the correct time zone.

Out of curiosity, I installed tzdata (apk add tzdata inside the running container) after reading #13070 even though #6421 suggests the volumes that I verified fix the time zone, and installing tzdata has corrected the discrepancies across Gitea properly visually. When Gitea triggers any scheduled workflows it is still doing so in UTC as expected.

Gitea Version

1.23.0+dev-669-ge546480d0a built with GNU Make 4.4.1, go1.23.3 : bindata, timetzdata, sqlite, sqlite_unlock_notify Docker image hash is sha256:a7ec154a7f566ac6c897716085d930f4bd911e457f4aeb19e66bad7e167e3ffe

Can you reproduce the bug on the Gitea demo site?

Not relevant.

Log Gist

No response

Screenshots

No response

Git Version

Not relevant.

Operating System

Docker host is Alpine Linux (Edge) Docker v27.3.1

How are you running Gitea?

Running on docker from gitea/gitea:nightly with default values for everything. Set env vars for the [mailer] section. Set the TZ variable as I set that for ALL my containers by default. Mounted /data/ on a docker local volume.

Database

PostgreSQL v16.4