Moby: ENV DEBIAN_FRONTEND noninteractive

Created on 10 Feb 2014  路  10Comments  路  Source: moby/moby

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?

Most helpful comment

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

ARG DEBIAN_FRONTEND=noninteractive

All 10 comments

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

/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?

closed by #4035

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

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

DEBIAN_FRONTEND=newt

Resource link

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

hmmm https://github.com/docker/docker/pull/9176 :-)

What is the consensus on the best practice here?

@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

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

ARG DEBIAN_FRONTEND=noninteractive

Was this page helpful?
0 / 5 - 0 ratings