"docker debug" does not honor timezone

So I run a few amd64 containers based on OpenSUSE LEap 15.4 and RHEL 9.4 with Docker Desktop for Mac v4.33 on an M3 MacBook Pro (Rosetta enabled).

In all of them TZ=Europe/Berlin is set and when I run a shell (bash or zsh) with docker exec -it <container> <shell>, the date command prints the current time in my timezone, just as expected.

Not so if I use docker debug <container>, though: date prints UTC and seems to ignore the TZ env variable. Also running tzselect does not seem to have any effect, unfortunately…

Can this be fixed? Am I doing something wrong? Is this a known issue?

Check Github, potentially create an issue there.

I could not reproduce it with httpd:2.4. Which image did you try? Was it a publicly available image? If not, can you test it with one?

Sorry for the delayed response, here’s what I see:

“docker exec” gets it right (Europe/Berlin=CET in November):

> ╭─lhaeger@MacBook
> ╰─➤   docker exec -it dirxml.idm.local zsh
> 
> ╭─root@dirxml /var/log/idm
> ╰─➤  export | grep TZ
> TZ=Europe/Berlin
> 
> ╭─root@dirxml /var/log/idm
> ╰─➤  date +%z_%Z
> +0100_CET

“docker debug” seems to ignore the “Berlin” part or the TZ env var and settles for GMT+0000 (Greenwich is in Europe after all, so that’s correct, right?).

╭─lhaeger@MacBook
╰─➤  docker debug dirxml.idm.local
         ▄
     ▄ ▄ ▄  ▀▄▀
   ▄ ▄ ▄ ▄ ▄▇▀  █▀▄ █▀█ █▀▀ █▄▀ █▀▀ █▀█
  ▀████████▀    █▄▀ █▄█ █▄▄ █ █ ██▄ █▀▄
   ▀█████▀                        DEBUG

Builtin commands:
- install [tool1] [tool2] ...    Add Nix packages from: https://search.nixos.org/packages
- uninstall [tool1] [tool2] ...  Uninstall NixOS package(s).
- entrypoint                     Print/lint/run the entrypoint.
- builtins                       Show builtin commands.

Checks:
✓ distro:            openSUSE Leap 15.4
✓ entrypoint linter: no errors (run 'entrypoint' for details)

This is an attach shell, i.e.:
- Any changes to the container filesystem are visible to the container directly.
- The /nix directory is invisible to the actual container.
                                                                                                                                                                                                     Version: 0.0.37

root@dirxml /home/nds [dirxml.idm.local]
docker > export | grep TZ
TZ=Europe/Berlin

root@dirxml /home/nds [dirxml.idm.local]
docker > date +%z_%Z
+0000_Europe

Trying to set the tz with tzselect in “docker debug” only gets me:

root@dirxml /home/nds [dirxml.idm.local]
docker > tzselect
/nix/var/nix/profiles/default/bin/tzselect: line 179: /nix/store/p852ydpr8zlq0szh5fpvvbzzjaq2ydp5-glibc-2.39-52/share/zoneinfo/iso3166.tab: No such file or directory
/nix/var/nix/profiles/default/bin/tzselect: time zone files are not set up correctly

tzselect does work with “docker exec” in the running container, though:


╭─root@dirxml /var/log/idm
╰─➤  tzselect    
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", "TZ", or "time".
1) Africa							     6) Atlantic Ocean							11) coord - I want to use geographical coordinates.
2) Americas							     7) Australia							12) TZ - I want to specify the timezone using the Posix TZ format.
3) Antarctica							     8) Europe								13) time - I know local time already.
4) Arctic Ocean							     9) Indian Ocean
5) Asia								    10) Pacific Ocean
#? 8
Please select a country whose clocks agree with yours.
1) Albania		   8) Croatia		    15) Germany		      22) Italy			29) Moldova		  36) Portugal		    43) Spain		      50) Åland Islands
2) Andorra		   9) Cyprus		    16) Gibraltar	      23) Jersey		30) Monaco		  37) Romania		    44) Sweden
3) Austria		  10) Czech Republic	    17) Greece		      24) Latvia		31) Montenegro		  38) Russia		    45) Switzerland
4) Belarus		  11) Denmark		    18) Guernsey	      25) Liechtenstein		32) Netherlands		  39) San Marino	    46) Turkey
5) Belgium		  12) Estonia		    19) Hungary		      26) Lithuania		33) North Macedonia	  40) Serbia		    47) Ukraine
6) Bosnia & Herzegovina	  13) Finland		    20) Ireland		      27) Luxembourg		34) Norway		  41) Slovakia		    48) United Kingdom
7) Bulgaria		  14) France		    21) Isle of Man	      28) Malta			35) Poland		  42) Slovenia		    49) Vatican City
#? 15
Please select one of the following timezones.
1) Büsingen
2) most of Germany
#? 2

Based on the following information:

	Germany
	most of Germany

TZ='Europe/Berlin' will be used.
Selected time is now:	Thu Nov  7 11:43:17 CET 2024.
Universal Time is now:	Thu Nov  7 10:43:17 UTC 2024.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
	TZ='Europe/Berlin'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Europe/Berlin

The image in question is provided by a sw vendor but not publicly available. It’s based on openSUSE LEAP, though. I’ve ssen the same behaviour on RedHat UBI 9-based images.

Can you share exact commands that I can run on my machine to reproduce the issue?

Ok, found the cause and solution: timezone data is missing in those images, a simple

microdnf install tzdata

fixes it.