186

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?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
peachykeen
  • 4,143
  • 4
  • 30
  • 49

4 Answers4

210

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....

Leo K
  • 5,189
  • 3
  • 12
  • 27
  • 29
    Can you provide a reference for the "it's safe to ignore it" comment? – Zak Jan 01 '19 at 13:33
  • 28
    It is a known warning, see for example here: https://github.com/phusion/baseimage-docker/issues/319#issuecomment-262662165 (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 02 '19 at 15:56
  • 5
    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 08 '20 at 20:31
78

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)

Dweeberly
  • 4,668
  • 2
  • 22
  • 41
KeyMaker00
  • 6,194
  • 2
  • 50
  • 49
  • 2
    I used "Alternative 2: On-the-fly" : very clean and convenient, I have no confusing warnings anymore – herve-guerin Mar 28 '20 at 18:26
  • 3
    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 '20 at 13:11
  • 1
    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 '21 at 19:46
  • Thanks KeyMaker00, this solved the problem on https://github.com/veevidify/laravel-apache-docker – Paul Preibisch Jun 23 '22 at 20:17
  • Since Alternative-1 is not working, please remove or mind crossing out it . It confuses people. – Fredrick Gauss Jun 30 '22 at 06:09
  • @FredrickGauss: Good call. It's done. – KeyMaker00 Jul 02 '22 at 08:21
  • ```DEBIAN_FRONTEND=noninteractive``` doesn't work on Ubuntu 22.04 / image `Ubuntu:jammy` for some reason. – hanshenrik Sep 23 '22 at 06:45
  • That is not answer for the question, that is an answer for what to do to get rid of subsequent warnings that can occur after installing apt-utils. – Wodzu Jan 25 '23 at 13:36
5

Please run apt-get install apt-utils and voilà. Installed and no warnings.

Sadiel
  • 1,344
  • 3
  • 18
  • 33
user18226822
  • 67
  • 1
  • 1
  • 1
    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](/help/how-to-answer). – Community Feb 17 '22 at 12:23
  • I assume "viola" is an intentional pun, otherwise I would edit the typo... – Yunnosch Apr 30 '22 at 06:54
  • 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 05 '22 at 09:29
  • @theerrormagnet your comment saved me some time. – GaTechThomas Sep 15 '22 at 02:08
  • 1
    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 '22 at 06:44
  • @hanshenrik Your recommendation worked flawlessly for me. In my original code, I started with `apt-get update` (line 1), but would always get the error when I ran `apt-get install -y apt-utils` on line 2. I also had other `apt-get install`s after that and was not sure where the error was even coming from. I dropped your code in as a copy-paste replacement for line 2 and the error went away. As an experiment at the end, I also tested your code _without_ the `-q` modifier and the effect was the same. – Fatedx Apr 06 '23 at 00:05
-1

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

Ray Foss
  • 3,649
  • 3
  • 30
  • 31
  • 3
    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 '21 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 05 '21 at 19:43
  • 1
    If you just want to filter out warning messages you can use `DEBCONF_NOWARNINGS=yes` as well as `DEBIAN_FRONTEND=noninteractive`. – heurist Mar 27 '22 at 17:38