Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to install apt-utils on Docker because when I was just doing apt-get update , I was getting the error: debconf: delaying package configuration, since apt-utils is not installed . So I added a line to install apt-utils (along with curl ):

RUN apt-get update && apt-get install -y apt-utils && apt-get install -y curl

But, I am still getting that error leading me to believe that my command didn't work. Below is my output when I try to build the image.

Step 5/12 : RUN apt-get update && apt-get install -y apt-utils && apt-get install -y curl
 ---> Running in 6e6565ff01bd
Get:1 http://security.debian.org jessie/updates InRelease [94.4 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://deb.debian.org jessie Release.gpg [2420 B]
Get:4 http://deb.debian.org jessie Release [148 kB]
Get:5 http://security.debian.org jessie/updates/main amd64 Packages [624 kB]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.0 kB]
Get:7 http://deb.debian.org jessie/main amd64 Packages [9098 kB]
Fetched 10.1 MB in 6s (1541 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  libapt-inst1.5
The following NEW packages will be installed:
  apt-utils libapt-inst1.5
0 upgraded, 2 newly installed, 0 to remove and 24 not upgraded.
Need to get 537 kB of archives.
After this operation, 1333 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian/ jessie/main libapt-inst1.5 amd64 1.0.9.8.4 [169 kB]
Get:2 http://deb.debian.org/debian/ jessie/main apt-utils amd64 1.0.9.8.4 [368 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 537 kB in 0s (557 kB/s)
Selecting previously unselected package libapt-inst1.5:amd64.
(Reading database ... 21676 files and directories currently installed.)
Preparing to unpack .../libapt-inst1.5_1.0.9.8.4_amd64.deb ...
Unpacking libapt-inst1.5:amd64 (1.0.9.8.4) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_1.0.9.8.4_amd64.deb ...
Unpacking apt-utils (1.0.9.8.4) ...
Setting up libapt-inst1.5:amd64 (1.0.9.8.4) ...
Setting up apt-utils (1.0.9.8.4) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Reading package lists...
Building dependency tree...
Reading state information...
curl is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
Removing intermediate container 6e6565ff01bd
 ---> f65e29c6a6b9
Step 6/12 : RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash
 ---> Running in f5764ba56103
Detected operating system as debian/8.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing debian-archive-keyring which is needed for installing
apt-transport-https on many Debian systems.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/github_git-lfs.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.
The repository is setup! You can now install packages.
Removing intermediate container f5764ba56103
 ---> a4e64687ab73

What is causing this and how can I fix it?

This is not actually an error and it is safe to ignore it. I have built a large number of container images without ever having apt-utils on any of them and regardless of this warning message, all package installs go through and work normally.

Anyway, if you want to have apt-utils - install it. It will give you this warning once and then it will disappear for future invocations of apt-get (as you can see in your own log, curl got installed without that message).

NOTE if you install apt-utils, you will get other warnings (because now the installer can run interactive config and will attempt that and fail). To suppress those and have packages that have interactive config with their defaults, run apt-get like this: DEBIAN_FRONTEND=noninteractive apt-get install -y pkgs....

It is a known warning, see for example here: github.com/phusion/baseimage-docker/issues/… (this happens with packages that have interactive configuration where it asks you questions - it means that interactive configuration is skipped, but you don't even need that and want the defaults anyway, because you're running an automatic install). – Leo K Jan 2, 2019 at 15:56 It's not always an ignorable warning, it depends on the specific package you're installing. Sometimes the configuration is necessary and you'll have to either do an interactive install or find some other way to provide it with the configuration it needs. – Ken Williams Feb 8, 2020 at 20:31

After searching over the Internet, I have found some alternatives worth mentioning, instead of every time putting DEBIAN_FRONTEND=noninteractive in front of apt-get install -y {your-pkgs}:

Alternative 1: ARG DEBIAN_FRONTEND=noninteractive

Important: According to the feedbacks alternative 2 & 3 work for most of you, while alternative 1 does not. This is why this alternative is crossed out, but is kept for the sake of traceability & completeness.

The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the --build-arg = flag. (Reference: [6])

Solution characteristics:

  • ARG directive is set only during the build
  • The option 'noninteractive' is set as default value for the build-time only.
  • Since it is an argument, it can be changed by passing another value for this argument with e.g. docker build --build-arg DEBIAN_FRONTEND=newt
  • Example:

    ARG DEBIAN_FRONTEND=noninteractive
    RUN apt-get -yq install {your-pkgs}
    

    Alternative 2: On-the-fly

    It is the solution from Leo K.

    Solution characteristics:

  • It can be set where is it needed. So a good fine-grained solution.
  • It can be set in a different value in a specific command, so it is not globally set.
  • The scope is the RUN and won't affect other directives.
  • Example:

    RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install {your-pkgs}
    

    Alternative 3: ENV DEBIAN_FRONTEND=noninteractive

    Setting ENV DEBIAN_FRONTEND noninteractive would also be an alternative but it is highly discouraged.

    Another way would be to set at the beginning and unset it at the end of the Dockerfile.

    Solution characteristics:

  • ENV directive will persists the environment variable after the build (not recommended), furthermore
  • It can be error prone if you forget to set it back to the default value.
  • Because it is set with ENV, it will be inherited by all images and containes built from the image, effectively changing their behaviour. (As mentioned in [1]) People using those images run into problems when installing software interactively, because installers do not show any dialog boxes.
  • The default frontend is DEBIAN_FRONTEND=newt (see [2], so it has to be set at the end of the file.
  • Example:

    # Set for all apt-get install, must be at the very beginning of the Dockerfile.
    ENV DEBIAN_FRONTEND noninteractive
    # Non-interactive modes get set back.
    ENV DEBIAN_FRONTEND newt
    

    Alternative 4: RUN export DEBIAN_FRONTEND=noninteractive

    Solution characteristics:

  • Quite similar to the alternative 2
  • By decoupling, the cohesion is suffering: why there is an export of this variable and to what it belongs to (apt-get).
  • The scope is the RUN and won't affect other directives.
  • Example:

    # Set the frontend and then install your package
    RUN export DEBIAN_FRONTEND=noninteractive && \
        apt-get -yq install {your-pkgs} && \
    

    More to read (references)

  • ENV DEBIAN_FRONTEND noninteractive
  • debconf: delaying package configuration, since apt-utils is not installed
  • point out that ENV DEBIAN_FRONTEND will persist, so its not recommended
  • Docker frequently asked questions (FAQ)
  • Debian Installer Parameters
  • Official documentation - ARG
  • I used "Alternative 2: On-the-fly" : very clean and convenient, I have no confusing warnings anymore – herve-guerin Mar 28, 2020 at 18:26 I choose Alternative 1 and still get warnings. My Dockerfile begins with FROM node:10.16.2 WORKDIR /usr/src/app ARG DEBIAN_FRONTEND=noninteractive and I run docker build --no-cache -t node-10-16-2-plus-chrome . – Marecky Oct 14, 2020 at 13:11 Note, alternative 1 will not work! Because build args are only interpreted in the Dockerfile when referencing them with the dollar sign. Build args are not the same as environment variables, and args won't be propagated to the run layer (unlike env vars do). – Andrey Volkov Apr 24, 2021 at 19:46 Since Alternative-1 is not working, please remove or mind crossing out it . It confuses people. – Fredrick Gauss Jun 30, 2022 at 6:09 Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Feb 17, 2022 at 12:23 Before you can install any apt package in Docker you need to run apt update and apt update will already show the warning. – theerrormagnet Sep 5, 2022 at 9:29 at least in Ubuntu 22.04, running that command also generates the warning. you'll have to do something like apt-get install -yq apt-utils >/dev/null 2>&1 to really install it without seeing the warning x.x – hanshenrik Sep 23, 2022 at 6:44

    This is an ongoing issue with no great solution... I went with this, it's sub-optimal, but it works:

    ARG DEBIAN_FRONTEND=noninteractive
    RUN apt-get update && apt-get install -y apt-utils 2>&1 | \
        grep -v "^debconf: delaying package configuration, since apt-utils.*"
    

    Explanation:

  • grep -v reverse matches, lines starting with that will begone!
  • ARG is the new ENV if you don't need it at runtime.
  • We can then use apt-get all day without that error showing when building the image from scratch.
  • Proof that this works: https://asciinema.org/a/WJCDEYcxCIy6EF7eXw0MAnK3c

    that's not a fix or "best option". You're just visually filtering out the error, thereby cluttering your Dockerfile for nothing but aesthetics. – dfherr May 29, 2021 at 19:11 By best option, I didn't mean to imply good. I've replaced it with "sub optimal" to clarify. This acknowledges and dismisses the warning. It's functional since you get real state back and boosts the accessibility of serious errors. – Ray Foss Oct 5, 2021 at 19:43 If you just want to filter out warning messages you can use DEBCONF_NOWARNINGS=yes as well as DEBIAN_FRONTEND=noninteractive. – heurist Mar 27, 2022 at 17:38

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.