docker-library / buildpack-deps

MIT License
445 stars 113 forks source link

Ubuntu images have broken `/etc/timezone` file #161

Open satwell opened 1 month ago

satwell commented 1 month ago

All of the buildpack-deps ubuntu images have broken content in /etc/timezone:

% docker run --rm buildpack-deps:24.04-curl cat /etc/timezone
/UTC

The /etc/timezone file is supposed to be the name of a timezone, in the same format as the TZ environment variable. /UTC is invalid (note the slash at the beginning). The Debian-based buildpack-deps images have Etc/UTC in this file, which is correct.

The problem happens during installation of the tzdata package in the -curl images. tzdata has some friendly prompts to configure the timezone, and they're failing when stdin isn't available during the docker build. See the relevant portion of the build log:

Setting up tzdata (2024a-3ubuntu1.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC entries checked: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 8.)
debconf: falling back to frontend: Teletype
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa   3. Antarctica  5. Asia      7. Australia  9. Indian    11. Etc
  2. America  4. Arctic      6. Atlantic  8. Europe     10. Pacific
Geographic area: 
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 112.

Current default time zone: '/UTC'
Local time is now:      Sun Aug 11 00:16:25 UTC 2024.
Universal Time is now:  Sun Aug 11 00:16:25 UTC 2024.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

Use of uninitialized value $val in substitution (s///) at /usr/share/perl5/Debconf/Format/822.pm line 84, <GEN6> line 4.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/perl5/Debconf/Format/822.pm line 85, <GEN6> line 4.

Debian isn't affected by this bug because the debian images already have the tzdata package installed correctly.

The root cause here seems to be a bug in tzdata--it shouldn't fail in a way that writes an invalid configuration.

But it's easy to work around in buildpack-deps. Setting DEBIAN_FRONTEND=noninteractive when running apt-get install will prevent packages from trying to prompt for configuration.

tianon commented 1 month ago

The root cause here seems to be a bug in tzdata--it shouldn't fail in a way that writes an invalid configuration.

Is this filed in an upstream bug tracker somewhere? :eyes:

satwell commented 1 month ago

I've filed a bug against Debian tzdata at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1078604.