mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-04-28 11:15:36 +02:00
Support reading timezone info from env (#748)
* add tzdata package * updated timezone documentation * add missing bind-mount from updated docs * Add timezone deprecation warnings and related logging to backup commands * fix lint CI job error * Address PR comments: refactor timezone deprecation warning handling, update docs
This commit is contained in:
committed by
GitHub
parent
0955d6fe80
commit
6a83ce4034
@@ -1,26 +1,55 @@
|
||||
---
|
||||
title: Set the timezone the container runs in
|
||||
title: Setting the Time Zone
|
||||
layout: default
|
||||
parent: How Tos
|
||||
nav_order: 8
|
||||
---
|
||||
|
||||
# Set the timezone the container runs in
|
||||
# Setting the Time Zone
|
||||
|
||||
By default a container based on this image will run in the UTC timezone.
|
||||
As the image is designed to be as small as possible, additional timezone data is not included.
|
||||
In case you want to run your cron rules in your local timezone (respecting DST and similar), you can mount your Docker host's `/etc/timezone`, `/etc/localtime`, and `/usr/share/zoneinfo` in read-only mode:
|
||||
## Use Environment Variable `TZ`
|
||||
|
||||
A container started using this image will default to UTC. To modify the time zone, set the `TZ` environment variable to a valid [tz database time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones):
|
||||
|
||||
```yml
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:v2
|
||||
image: offen/docker-volume-backup:latest
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
volumes:
|
||||
- data:/backup/my-app-backup:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /usr/share/zoneinfo:/usr/share/zoneinfo:ro
|
||||
|
||||
volumes:
|
||||
data:
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
This approach is preferred because it:
|
||||
|
||||
- avoids dependency on host configuration
|
||||
- works consistently across environments
|
||||
|
||||
### Compatibility
|
||||
|
||||
- Bind-mounting timezone files will continue to work if `TZ` is not set.
|
||||
- If `TZ` is set, it takes precedence over any bind-mounted timezone configuration.
|
||||
- An invalid `TZ` value will cause the container to default to UTC.
|
||||
|
||||
:warning: **Deprecation Warning**
|
||||
The method described below (bind-mounting files from the host) is **deprecated**. Please use the new method described above (`TZ`)
|
||||
|
||||
> ```yml
|
||||
> services:
|
||||
> backup:
|
||||
> image: offen/docker-volume-backup:latest
|
||||
> volumes:
|
||||
> - data:/backup/my-app-backup:ro
|
||||
> - /etc/timezone:/etc/timezone:ro
|
||||
> - /etc/localtime:/etc/localtime:ro
|
||||
> - /usr/share/zoneinfo:/usr/share/zoneinfo:ro
|
||||
>
|
||||
> volumes:
|
||||
> data:
|
||||
> ```
|
||||
Reference in New Issue
Block a user