Skip to content

ENV DEBIAN_FRONTEND noninteractive #4032

Closed

Description

@SvenDowideit

should we really expect users of our deb base images to add

ENV DEBIAN_FRONTEND noninteractive to the start of all their Dockerfiles, or is this actually a reasonable default that we could set for them?

Activity

  1. tianon commented on Feb 10, 2014

    @tianon
    Member

    This is definitely not a reasonable default, and setting it via ENV should be actively discouraged.

    APT is smart enough to detect that it's not being run interactively, but it throws out some pretty ugly looking warnings (that thanks to our new build stuff are red now), and setting this hides them.

    The reason it's not a good default is that if I docker run -i -t ... bash, I'm now interactive, and this variable being set is very, very wrong. This is exactly why it's set in-line in our root Dockerfile, and not via ENV (ie, RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq ...).

  2. SvenDowideit commented on Feb 10, 2014

    @SvenDowideit
    ContributorAuthor

    /me ponders where to document that...

    Does this mean Dockerfile authors should avoid using RUN DEBIAN_FRONTEND=noninteractive apt-get install ... until there's a problem and then only add it to those that fail, or that every apt-get line needs to be littered with something most of them won't even know exists?

    (and awful lot of the postgreSQL example complains without)

    alternativly, could I ENV set it at the top, and then ENV unset it after?

  3. SvenDowideit commented on Feb 14, 2014

    @SvenDowideit
    ContributorAuthor

    closed by #4035

  4. pmorch commented on Jun 15, 2014

    @pmorch

    I saw the note in the docs that

    Note: One example where this can cause unexpected consequenses, is setting ENV DEBIAN_FRONTEND noninteractive. Which will persist when the container is run interactively; for example: docker run -t -i image bash

    and am now thinking "Ok, so what should I do instead?" The subsquent google search landed me here. Neither this issue nor the docs give a clear recommendation...

    So what is the canonical way to run apt-get install?

    RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package
    

    Seems to be the way to do it. @SvenDowideit hints at:

    alternativly, could I ENV set it at the top, and then ENV unset it after?

    But is it possible to "then ENV unset it after"? A single-arg:

    ENV DEBIAN_FRONTEND
    

    Doesn't work, and I can't find a undef/NULL/nil value for ENV in the docs.

    I'd love to hear/read the canonical way to do it somewhere...

  5. czerasz commented on Jul 28, 2014

    @czerasz
    Contributor

    @pmorch You could just set it to it's default value

    DEBIAN_FRONTEND=newt
    

    Resource link

  6. shaunc commented on Mar 29, 2015

    @shaunc

    Maybe there should be a BUILDENV command that just sets environment during build :)

  7. duglin commented on Mar 29, 2015

    @duglin
    Contributor

    hmmm #9176 :-)

  8. added a commit that references this issue on May 6, 2015
  9. drastik commented on Dec 10, 2015

    @drastik

    What is the consensus on the best practice here?

  10. thaJeztah commented on Dec 10, 2015

    @thaJeztah
    Member

    @drastik best practice is to not use ENV, because that will make the env-var persist in the final image.

    In most cases, omitting "DEBIAN_FRONTEND" is harmless and only produces some warnings during build (which can be ignored). If really needed, RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package should work

  11. markriggins commented on Mar 4, 2016

    @markriggins

    The new ARG directive in the Dockerfile can set this only during the build

    ARG DEBIAN_FRONTEND=noninteractive

  12. 36 remaining items

  13. tianon commented on Mar 19, 2024

    @tianon
    Member

    Since this is clearly a popular place for folks to link / reference for this issue, I'd like to return to it to point out that https://bugs.debian.org/929417 is fixed in debconf version 1.5.81 (Debian Bookworm/12+, Ubuntu Lunar/23.04+), and thus DEBIAN_FRONTEND shouldn't be necessary in any cases anymore in recent releases of those distributions.

  14. rgov commented on Oct 22, 2024

    @rgov

    @tianon: I'd like to return to it to point out that https://bugs.debian.org/929417 is fixed in debconf version 1.5.81 (Debian Bookworm/12+, Ubuntu Lunar/23.04+), and thus DEBIAN_FRONTEND shouldn't be necessary in any cases anymore in recent releases of those distributions.

    I'm not an expert but it looks the corresponding change is to "Make Readline frontend check that stdin is a tty" -- and it seems to be that was the intended behavior before, only now it's done slightly differently. Either way, this just causes DEBIAN_FRONTEND=readline to error out if there's no controlling TTY, right? This patch doesn't implicitly switch to noninteractive.

  15. tianon commented on Oct 23, 2024

    @tianon
    Member

    It makes the frontend error out, not the apt-get install, so here's how that plays out in practice:

    debconf: unable to initialize frontend: Dialog
    debconf: (TERM is not set, so the dialog frontend is not usable.)
    debconf: falling back to frontend: Readline
    debconf: unable to initialize frontend: Readline
    debconf: (This frontend requires a controlling tty.)
    debconf: falling back to frontend: Teletype
    

    (ie, the end result is DEBIAN_FRONTEND=teletype, which should "just work" appropriately)

  16. nfox18212 commented on Mar 11, 2025

    @nfox18212

    So just to clarify, if I want to run apt inside a container non-interactively, is putting it before every apt transaction in the dockerfile the intended way of doing that?

    RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package
    

    Or should I use the ARG directive? As in

    ARG DEBIAN_FRONTEND=noninteractive
    

    and then the environment variable will automatically be unset after build, so any RUN directive I use to install packages will just work?

  17. theAkito commented on Mar 11, 2025

    @theAkito

    So just to clarify, if I want to run apt inside a container non-interactively, is putting it before every apt transaction in the dockerfile the intended way of doing that?

    RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q package
    

    Or should I use the ARG directive? As in

    ARG DEBIAN_FRONTEND=noninteractive
    

    and then the environment variable will automatically be unset after build, so any RUN directive I use to install packages will just work?

    If you would need to set the environment variable, this wouldn't work with an ARG, if the image did not specifically handle that ARG, which almost no image does.

    However, as far as I have heard, the usage of APT inside a container is already handled since a long enough while and you do not need to worry about setting this environment variable yourself manually, anymore.

    Just use APT, as you would normally do. It will work, as long as you do not specifically trigger prompts by, for example, settings the Debian Frontend to interactive on purpose. ;)

  18. added a commit that references this issue on Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions