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 confi
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
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 builddocker 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:
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 begging and unset it at the end of the Dockerfile.
Solution characteristics:
ENV
directive will persists the environment variable after the build (not recommended), furthermoreENV
, 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.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:
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)