Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TZ env var doesn't work due to tzdata package missing #51

Open
michael-robbins opened this issue Feb 6, 2022 · 5 comments
Open

TZ env var doesn't work due to tzdata package missing #51

michael-robbins opened this issue Feb 6, 2022 · 5 comments

Comments

@michael-robbins
Copy link

Currently setting TZ="Australia/Melbourne" has no effect on the containers timezone due to the tzdata package missing.

Before:

root@grafana-backup:~# TZ="Australia/Melbourne" date
Sun Feb  6 03:14:14 Australia 2022
root@grafana-backup:~# TZ="UTC" date
Sun Feb  6 03:14:23 UTC 2022

After tzdata install:

root@grafana-backup:~# TZ="Australia/Melbourne" date
Sun Feb  6 14:15:11 AEDT 2022
root@grafana-backup:~# TZ="UTC" date
Sun Feb  6 03:15:16 UTC 2022

Could we please add this to the container image/setup so we don't have to specify the cron expression as UTC?

@varhub
Copy link
Contributor

varhub commented Feb 6, 2022

Could you try mounting this instead?

-v /etc/timezone:/etc/timezone:ro
-v /etc/localtime:/etc/localtime:ro

@michael-robbins
Copy link
Author

Mounting in both the above still results in the same 'time' reported as both TZ's above.

@varhub
Copy link
Contributor

varhub commented Feb 6, 2022

Thats wreid. Could you replicate bellow commands and paste your output?

$ cat /etc/timezone
Europe/Madrid
$ docker run --rm bash date
Sun Feb  6 11:04:35 UTC 2022
$ docker run --rm -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro bash date
Sun Feb  6 12:04:40 CET 2022

[EDIT]
Also output of cat /etc/os-release if available of your container

@michael-robbins
Copy link
Author

michael-robbins commented Feb 6, 2022

I'm using the provided docker-volume-backup container with the Dockerfile in the root of the repo.

root@emojirades-backup:~# ls -l /etc/timezone
-rw-r--r-- 1 root root 8 Nov  6 02:39 /etc/timezone
root@emojirades-backup:~# ls -l /etc/localtime
-rw-r--r-- 1 root root 118 Oct 25 23:58 /etc/localtime
root@emojirades-backup:~# cat /etc/timezone
Etc/UTC
root@emojirades-backup:~# date
Sun Feb  6 11:54:57 Australia 2022
root@emojirades-backup:~# TZ='Australia/Melbourne' date
Sun Feb  6 11:55:09 Australia 2022
root@emojirades-backup:~# TZ='UTC' date
Sun Feb  6 11:55:15 UTC 2022

Feel free to try emulate it yourself using the Dockerfile from this repo.

$ docker inspect emojirades-backup
...
        "HostConfig": {
            "Binds": [
                "/var/run/docker.sock:/var/run/docker.sock:ro",
                "/etc/timezone:/etc/timezone:ro",
                "/etc/localtime:/etc/localtime:ro"
            ],
        },
...
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/var/run/docker.sock",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/etc/timezone",
                "Destination": "/etc/timezone",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/etc/localtime",
                "Destination": "/etc/localtime",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            }
        ]
...

@davidski
Copy link

I hate to metoo on an issue, but given the age on this I'll risk chiming in that I experience this problem as well (TZ setting is ineffective, with both /etc/localtime and /etc/timezone bind mounted in). PR #52 was closed without comment. I'd love to see this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants