DEBIAN_FRONTEND noninteractive in Docker

Are you trying to set DEBIAN_FRONTEND=noninteractive in docker so that no question/dialog is asked during apt-get install? 

See why it is discouraged.

Debian_frontend noninteractive mode is useful when you need zero interaction while installing or upgrading the system via apt. It accepts the default answer for all questions. 

It might mail an error message to the root user, but that's it all. 

Otherwise, it is totally silent and humble, a perfect frontend for automatic installs.

Because it is inherited by all images and containers built from the image, effectively changing their behavior.

Setting DEBIAN_FRONTEND to noninteractive is mainly a 'cosmetic' change, we highly discourage changing it.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Docker related queries.

In this context, we shall look into why we discourage changing the default value of DEBIAN_FRONTEND.

Why DEBIAN_FRONTEND=noninteractive mode is discouraged in Docker files?

Here, you will see why you should not set DEBIAN_FRONTEND to noninteractive.

Generally, while building Docker images on Debian and Ubuntu you may have seen errors like:

unable to initialize frontend: Dialog

However, these errors don't stop the building of the image instead it informs you that the installation process tried to open a dialog box, but couldn't. 

Generally, we can safely ignore these errors.

In some cases, few people try to change this environment variable inside the Dockerfile using:

ENV DEBIAN_FRONTEND=noninteractive

This prevents the installer from opening dialog boxes during the installation process. 

As a result, it stops the errors from displaying.

This might sound like a good idea but it may have side effects.

Common error setting DEBIAN_FRONTEND=noninteractive in docker

Let us fix an error our customer encountered.

One of our customers set the following environment so that no question/dialog pops up during apt-get install:

ENV DEBIAN_FRONTEND noninteractive # export DEBIAN_FRONTEND="noninteractive"

Then while building an image from a Dockerfile, at the end of one specific Debian/Ubuntu package install (using apt-get install), package configuration debconf says:

debconf: unable to initialize frontend: Noninteractive # export DEBIAN_FRONTEND="noninteractive"
debconf: (Bareword "Debconf::FrontEnd::Noninteractive" not allowed while "strict subs" in use at (eval 35) line 3, <> line 1.)
debconf: falling back to frontend: Noninteractive
Subroutine BEGIN redefined at (eval 36) line 2, <> line 1.

First of all, we highly discourage setting DEBIAN_FRONTEND to noninteractive via ENV

Because the environment variable persists after the build, e.g. when you run docker exec -it … bash. 

The setting would not make sense here.

Here are the two possible ways:

Setting it via ARG as this is only available during build:

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq install {your-package}

When required, setting it on-the-fly:

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq install {your-package}

[Need urgent assistance with Docker-related queries? – We're available 24*7. ]


This article will guide you on why you should not set the DEBIAN_FRONTEND value to noninteractive is a 'cosmetic' change. If you really need to change its setting, make sure to change it back to its default value afterward. Simply prepending an apt command with DEBIAN_FRONTEND=something does not persist after the single command to which it is applied. 

apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. 

It will do this for all repositories and PPAs.

To Preserve Configuration Files:

During package installation or upgrade, Debian may wish to prompt the user on overwriting a configuration file. 

This preference can be appended to the installation command:

apt-get install -q -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \

This command will instruct the installer to quiet any messages, assume yes, and then upgrade configuration files if no changes are present in the new package.