debconf: unable to initialize frontend: Dialog during apt-get install in a Docker build is a warning, not the reason a build fails: a package wanted to ask a question, and there is no terminal to ask it on. Add ARG DEBIAN_FRONTEND=noninteractive to the Dockerfile and the packages take their default answers silently.

Use ARG, not ENV: the setting then applies to the build steps only and does not stay in the image, where it would surprise anyone who later runs apt-get interactively inside a container.

The error

#5 9.005 Setting up tzdata (2026e-0ubuntu0.24.04.1) ...
#5 9.064 debconf: unable to initialize frontend: Dialog
#5 9.064 debconf: (TERM is not set, so the dialog frontend is not usable.)
#5 9.064 debconf: falling back to frontend: Readline
#5 9.064 debconf: unable to initialize frontend: Readline
#5 9.064 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.)
#5 9.064 debconf: falling back to frontend: Teletype
#5 9.083 Configuring tzdata
#5 9.083 Please select the geographic area in which you live. Subsequent configuration
...
#5 9.083 Geographic area: 

The build still finished with exit code 0. If your build fails, the real error is further down the log, not in these lines.

Why it happens

Debian and Ubuntu packages ask configuration questions through debconf, which tries a list of front ends in turn. Dialog needs a terminal and TERM, which a RUN step does not have; Readline needs a Perl module the base image does not ship; Teletype finally prints the question to a log nobody can answer. Here tzdata asked for a geographic area, read no answer and fell back on its default.

The noise is harmless, but the fallback is not always what you want. In this test the image built without the setting kept /UTC in /etc/timezone, while the one built with it kept Etc/UTC. Telling debconf up front that nobody will answer gives the defaults without the guesswork.

The fix

FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata

Built again with --no-cache, the step went straight from Setting up tzdata to Run 'dpkg-reconfigure tzdata' if you wish to change it. with no debconf lines. The separate line debconf: delaying package configuration, since apt-utils is not installed stays in both builds; it is also harmless.

How it was reproduced

A two-line Dockerfile, FROM ubuntu:24.04 and RUN apt-get update && apt-get install -y tzdata, built with docker build --no-cache --progress=plain -t fix8-bld-p4 fix8-bld-p4 on Docker Desktop engine 29.9.2. tzdata was version 2026e-0ubuntu0.24.04.1. The fixed Dockerfile was built the same way, and cat /etc/timezone was run in a container from each image. Folder and tag names are this test's own.

Frequently asked

Is debconf unable to initialize frontend Dialog an error?
No. It is a warning that no terminal is available for package questions. debconf falls back to another front end and the build continues; a failing build has its real error elsewhere in the log.
Should DEBIAN_FRONTEND be ARG or ENV in a Dockerfile?
Use ARG. It applies to the RUN steps of the build and is not stored in the final image, so interactive apt use inside a running container behaves normally.
How do I stop tzdata asking for a timezone in Docker?
Set ARG DEBIAN_FRONTEND=noninteractive before the RUN that installs tzdata. The package then takes its default without printing the question.

More decoded errors in the Fixes category. If apt cannot find the package at all, see 'Unable to locate package'.