Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Having issues installing apt-utils

Tags:

docker

apt

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?

like image 254
peachykeen Avatar asked Sep 27 '22 19:09

peachykeen


2 Answers

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

like image 191
Leo K Avatar answered Oct 20 '22 05:10

Leo K


After searching over the Internet, I have found some alternatives worth to be mentioned, 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, but is kept for traceability & completeness sake.

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
like image 74
KeyMaker00 Avatar answered Oct 20 '22 06:10

KeyMaker00