Alpine image does not respect TZ environment variable #1575

Closed
opened 2025-10-09 17:20:46 +03:00 by OVERLORD · 8 comments
Owner

Originally created by @snevas on GitHub.

Alpine image does not respect TZ environment variable

When starting the latest alpine image, UTC time is used. This breaks fail2ban

Your environment

  • Bitwarden_rs version: 1.17.0
  • Install method: Docker image
  • Clients used: Web
  • Reverse proxy and version: nginx 1.14.2-2+deb10u3
  • Other relevant information: TZ=Europe/Amsterdam

Steps to reproduce

Only changed image: 'bitwardenrs/server' to image: 'bitwardenrs/server:alpine'

Expected behaviour

Would respect TZ-variable

Actual behaviour

Was UTC time (-2 hours)

Relevant logs

'bitwardenrs/server':

bitwarden | [2020-10-22 15:10:34.092][start][INFO] Rocket has launched from http://0.0.0.0:80

'bitwardenrs/server:alpine':

bitwarden | [2020-10-22 13:15:00.005][start][INFO] Rocket has launched from http://0.0.0.0:80

Originally created by @snevas on GitHub. <!-- # ### NOTE: Please update to the latest version of bitwarden_rs before reporting an issue! This saves you and us a lot of time and troubleshooting. See: https://github.com/dani-garcia/bitwarden_rs/issues/1180 # ### --> <!-- Please fill out the following template to make solving your problem easier and faster for us. This is only a guideline. If you think that parts are unnecessary for your issue, feel free to remove them. Remember to hide/obfuscate personal and confidential information, such as names, global IP/DNS addresses and especially passwords, if necessary. --> ### Alpine image does not respect TZ environment variable When starting the latest alpine image, UTC time is used. This breaks fail2ban ### Your environment <!-- The version number, obtained from the logs or the admin diagnostics page --> <!-- Remember to check your issue on the latest version first! --> * Bitwarden_rs version: 1.17.0 <!-- How the server was installed: Docker image / package / built from source --> * Install method: Docker image * Clients used: Web * Reverse proxy and version: nginx 1.14.2-2+deb10u3 * Other relevant information: TZ=Europe/Amsterdam ### Steps to reproduce Only changed image: 'bitwardenrs/server' to image: 'bitwardenrs/server:alpine' ### Expected behaviour Would respect TZ-variable ### Actual behaviour Was UTC time (-2 hours) ### Relevant logs <!-- Share some logfiles, screenshots or output of relevant programs with us. --> 'bitwardenrs/server': > bitwarden | [2020-10-22 15:10:34.092][start][INFO] Rocket has launched from http://0.0.0.0:80 'bitwardenrs/server:alpine': > bitwarden | [2020-10-22 13:15:00.005][start][INFO] Rocket has launched from http://0.0.0.0:80
OVERLORD added the buglow priority labels 2025-10-09 17:20:46 +03:00
Author
Owner

@snevas commented on GitHub:

I think the 3.5MB would justify timezone support. But that's up to @dani-garcia .

Adding the package manually would break my auto-updating and I won't use this image without timezone support because it breaks fail2ban.

@snevas commented on GitHub: I think the 3.5MB would justify timezone support. But that's up to @dani-garcia . Adding the package manually would break my auto-updating and I won't use this image without timezone support because it breaks fail2ban.
Author
Owner

@briffle commented on GitHub:

By default, alpine does not include the tzdata package. ( https://gitlab.alpinelinux.org/alpine/aports/-/issues/5543 ) It adds 3.5MB of space to the image, which is rather significant compared to the bare alpine image

To use the timezones, you would need to use apk to install tzdata.

@briffle commented on GitHub: By default, alpine does not include the tzdata package. ( https://gitlab.alpinelinux.org/alpine/aports/-/issues/5543 ) It adds 3.5MB of space to the image, which is rather significant compared to the bare alpine image To use the timezones, you would need to use apk to install tzdata.
Author
Owner

@snevas commented on GitHub:

@davidkna still does not work. The alpine dockerfile is missing the tz package and hard sets UTC. See: https://quaded.com/docker-apline-configure-timezone/
and
https://github.com/dani-garcia/bitwarden_rs/blob/master/docker/amd64/Dockerfile.alpine

@snevas commented on GitHub: @davidkna still does not work. The alpine dockerfile is missing the tz package and hard sets UTC. See: https://quaded.com/docker-apline-configure-timezone/ and https://github.com/dani-garcia/bitwarden_rs/blob/master/docker/amd64/Dockerfile.alpine
Author
Owner

@snevas commented on GitHub:

Also adding the following volume did not work:

'/etc/localtime:/etc/localtime:ro'

@snevas commented on GitHub: Also adding the following volume did not work: > '/etc/localtime:/etc/localtime:ro'
Author
Owner

@davidkna commented on GitHub:

/etc/localtime might be a symlink. You could try /usr/share/zoneinfo/Europe/Amsterdam:/etc/localtime:ro instead. With podman you could also use either --tz=local or --tz=Europe/Amsterdam.

@davidkna commented on GitHub: `/etc/localtime` might be a symlink. You could try `/usr/share/zoneinfo/Europe/Amsterdam:/etc/localtime:ro` instead. With podman you could also use either `--tz=local ` or `--tz=Europe/Amsterdam`.
Author
Owner

@snevas commented on GitHub:

Retested and confirmed working! No need to add anything to the alpine image 👍

@snevas commented on GitHub: Retested and confirmed working! No need to add anything to the alpine image :+1:
Author
Owner

@polyzen commented on GitHub:

Making a read-only bind mount to the host's /etc/localtime seems to have worked for me. -v /etc/localtime:/etc/localtime:ro should be the option -- I had manually edited my container's config.v2.json to add the mount.

@polyzen commented on GitHub: Making a read-only bind mount to the host's `/etc/localtime` seems to have worked for me. `-v /etc/localtime:/etc/localtime:ro` should be the option -- I had manually edited my container's `config.v2.json` to add the mount.
Author
Owner

@polyzen commented on GitHub:

Seems like using the logtimezone = UTC option for your jail might be cleaner.

@polyzen commented on GitHub: Seems like using the `logtimezone = UTC` option for your jail might be cleaner.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#1575