docker-volume-backup
docker-volume-backup copied to clipboard
TZ env var doesn't work due to tzdata package missing
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?
Could you try mounting this instead?
-v /etc/timezone:/etc/timezone:ro
-v /etc/localtime:/etc/localtime:ro
Mounting in both the above still results in the same 'time' reported as both TZ's above.
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
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"
}
]
...
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!