29

I've set the following environment so that no question/dialog is asked during apt-get install:

ENV DEBIAN_FRONTEND noninteractive    # export DEBIAN_FRONTEND="noninteractive"

Which is equivalent to:

export DEBIAN_FRONTEND="noninteractive"

Yet, when 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.

Wow... I found my error. There's no way to put comment in ENV lines in Dockerfile. I'm going to answer myself as I'm sure this will bite some other people...

57

It should be actively discouraged to set the DEBIAN_FRONTEND to noninteractive via ENV. The reason is that the environment variable persists after the build, e.g. when you run docker exec -it ... bash. The setting would not make sense here.

There are two other possible ways:

  1. Set it via ARG as this only is available during build:

    ARG DEBIAN_FRONTEND=noninteractive
    RUN apt-get -qq install {your-package}
    
  2. Set it on-the-fly when required.

    RUN apt-get update && \
        DEBIAN_FRONTEND=noninteractive apt-get -qq install {your-package}
    
  • 8
    signed up only to vote up – André Werlang Mar 6 '17 at 22:36
  • @AndréWerlang: Me too! – gvgramazio Nov 26 '18 at 17:14
27

Ok, source of the problem was: you cannot use # to put comments on ENV lines in Dockerfiles because there's no delimiter to say "end of env variable", everything that is after variable name and the space immediately after is going to be in the variable.

i.e. with the Dockerfile line:

ENV DEBIAN_FRONTEND noninteractive    # export DEBIAN_FRONTEND="noninteractive"

The variable:

DEBIAN_FRONTEND

will contain exactly this whole line:

noninteractive    # export DEBIAN_FRONTEND="noninteractive"

and is equivalent to doing:

export DEBIAN_FRONTEND='noninteractive    # export DEBIAN_FRONTEND="noninteractive"'

I was almost cancelling my question, but with search engines and Stack Exchange, some people will probably find their mistake here some day ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.