GrepBoard/Manuals
605 manuals ·

Fix "debconf: unable to initialize frontend: Dialog" in Docker

·Tested on Ubuntu 24.04 (Docker) · tzdata 2026e · Docker Engine 29.9.2 · 2026-10·Test scope ↓·5 steps

Docker build "debconf: unable to initialize frontend" means apt tried to ask a question with no terminal. Set ARG DEBIAN_FRONTEND=noninteractive; preset tzdata.

output
debconf: unable to initialize frontend: Dialogdebconf: (TERM is not set, so the dialog frontend is not usable.)debconf: falling back to frontend: Readlinedebconf: unable to initialize frontend: Readlinedebconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC entries checked: /etc/perl …) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 8.)debconf: falling back to frontend: Teletype

A package is being installed without a terminal, as in a Dockerfile RUN apt-get install, and it wants to ask a configuration question, so debconf steps down through its display methods and fails each one. Add ARG DEBIAN_FRONTEND=noninteractive to turn questions off and the messages go away. Usually it is only a warning, but a package that really asks, such as tzdata, can hang the build or end up misconfigured, so do not ignore it.

[1] Check whether it is only the warning or an actual question. Look right below the debconf lines in the build log:

output
Configuring tzdataPlease select the geographic area in which you live. Subsequent configurationGeographic area: Current default time zone: '/UTC'

A printed prompt such as Geographic area: means it waited for input. In testing, the outcome depended on how stdin was connected:

stdinResult
closed (< /dev/null)the empty answer is taken and the time zone is set to the bogus value '/UTC', exit code 0
open (docker run -i, a pipe)stops at Geographic area:; killed by the 150-second timeout

Neither is what you want. One shows up as a CI timeout, the other as a wrong time zone.

[2] Turn questions off. debconf's noninteractive frontend "never interacts with you at all, and makes the default answers be used for all questions" (man 7 debconf). It is only needed at build time, so pass it as an ARG:

Dockerfile
FROM ubuntu:24.04ARG DEBIAN_FRONTEND=noninteractiveRUN apt-get update && apt-get install -y --no-install-recommends tzdata

Under the same conditions this removed both the debconf warnings and the question, and the time zone got its default:

output
Setting up tzdata (2026e-0ubuntu0.24.04.1) ...Current default time zone: 'Etc/UTC'

The remaining debconf: delaying package configuration, since apt-utils is not installed line is harmless.

[3] Use ARG, not ENV. The Dockerfile reference warns that ENV DEBIAN_FRONTEND=noninteractive "changes the behavior of apt-get, and may confuse users of your image." ENV stays in the finished image and in every container started from it, while ARG "is not persisted in the final image." You can also set it for a single command:

Dockerfile
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata

Put it **directly before apt-get install**. In the shell, VAR=value command applies to that one command only, so DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install … sets it for update and not for the install that asks the question.

[4] If the image needs a specific time zone, provide the answer before installing. noninteractive uses the default (UTC); for anything else, link /etc/localtime first:

Dockerfile
FROM ubuntu:24.04ARG DEBIAN_FRONTEND=noninteractiveRUN ln -fs /usr/share/zoneinfo/Asia/Seoul /etc/localtime \ && apt-get update && apt-get install -y --no-install-recommends tzdata

tzdata then picks up that link:

output
Current default time zone: 'Asia/Seoul'

[5] If you see the same warning outside a build, apt ran without a terminal, as in ssh server1 'sudo apt-get install -y …' or cron. Add DEBIAN_FRONTEND=noninteractive there too. sudo may not pass environment variables through, so put it after sudo: sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ….

If an install inside a build is cut off and you get dpkg was interrupted, see Fix apt "E: dpkg was interrupted". If the image you built dies with exec format error on another server, see Docker exec format error.

#docker#dockerfile#debconf#apt#tzdata