this post was submitted on 08 Dec 2024
29 points (96.8% liked)

Selfhosted

49133 readers
477 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

A lot of selfhosted containers instructions contain volume mounts like:

docker run ...
  -v /etc/timezone:/etc/timezone:ro \
  -v /etc/localtime:/etc/localtime:ro \
  ...

but all the times I tried to skip those mounts everything seemed to work perfectly.

Are those mounts only necessary in specific cases?

PS:

Bonus question: other containers instructions say to define the TZ variable. Is that only needed when one wants a container to use a different timezone than the host?

top 4 comments
sorted by: hot top controversial new old
[–] ptz@dubvee.org 17 points 6 months ago

Most containers default to UTC, and depending what you're running, that may be fine.

I only mount /etc/timezone / /etc/localtime if I'm running a container where it needs to be on the same timezone as the host (DB containers, anything where I want the logs in local time, etc). Not all containers use the TZ env var, so bind mounting the timezone files from the host is a guaranteed way to sync them.

[–] BCsven@lemmy.ca 15 points 6 months ago

For a lot of applications the correct time may not matter but for something like homeassstant or syncthing you want your container time to be correct on a restart

[–] DaGeek247@fedia.io 10 points 6 months ago

It's so the container has the correct local time. It doesn't matter unless you're trying to schedule things in the container and don't want to calculate the offset every time you do.

[–] Coelacanthus@lemmy.kde.social 3 points 6 months ago

Without it, the program just fallback to UTC. /etc/localtime and $TZ are two ways to specify timezone for programs. The program look up the later first, if it's empty and then use /etc/localtime. In theory, $TZ has better performance because of the glibc will not look up the last modified time of /etc/localtime when every calling of localtime lookup.