Are you willing to set DEBIAN_FRONTEND=noninteractive in docker so that no question/dialog is asked during apt-get install? Have a look at this blog to know why we discourage it.
noninteractive mode is useful when we need zero interaction while installing or upgrading the system via apt. However, setting this environment variable to noninteractive has an adverse effect. 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 Bobcares, we have seen several such Docker-related queries as part of our Docker Hosting Support for Docker users, web hosts, and online service providers.
Today we’ll discuss why we discourage changing the default value of DEBIAN_FRONTEND.
Why is DEBIAN_FRONTEND=noninteractive discouraged in Docker files?
Now let’s discuss why our Support Engineers suggest not to 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
Now let’s take a look at an error our customer came across and also let’s see the solution our Support Engineers provide.
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 any further assistance with Docker-related queries? – We’re available 24*7]
Conclusion
In short, setting the DEBIAN_FRONTEND value to noninteractive is a ‘cosmetic’ change, we highly discourage changing it. If you really need to change its setting, make sure to change it back to its default value afterward. Today, we saw how our Support Engineers resolve its related error.
0 Comments