You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ...).
Reacted by Artiom Neganov, Zach Blankenship, Philipp Kretzschmar, Martin Thoma, Brannon Dorsey, Rahul Butani, ecebuzz, Sameer Gautam, Oleg Kr, Norman Sue and 78 more
Reacted by Jianxin,Ren, Grégory Millasseau, Will, robotrapta and Michael Hutts
Reacted by KevinHock, José Cage , Aleksandar Puharic, Michelangelo Mori and Peter Willemsen
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?
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...
Reacted by Oliver Salzburg, George Gaál, José Cage and Zori Kostadinova
Reacted by Nhomar [Vauxoo], Benjamin Rizkowsky, Andy Jordan, Daniel Andrei Mincă, idralyuk-wiser, B, Sameer Gautam, meshup, SDekkers, Yurdik Cervantes and 8 more
Maybe there should be a BUILDENV command that just sets environment during build :)
Reacted by Ian Maddox, Chris Cowan, Wiktor Latanowicz, Andreas Zetterlund, Leah Sapan, Charlie Calvert, Sameer Gautam, Osiris, Dominik Froehlich, James Pirruccello and 8 more
@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
Reacted by Furiously Curious, Michael Schroll, meshup, Lee Xiang Wei, Connor McCormick, Eugen, emcee-ai, Andrei Radulescu, John Blischak, José Cage and 9 more
The new ARG directive in the Dockerfile can set this only during the build
ARG DEBIAN_FRONTEND=noninteractive
Reacted by Julio Guerra, Kam, stephan lindauer, peterjasc, Tanachat Nilanon, Philipp Kretzschmar, Davide Polonio, Dan Kubb, Sean Flanigan, Benji Visser and 100 more
Reacted by Jemma Nelson, Zach Prado and lordadamson
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.
Reacted by Anatoly Kamchatnov, Bryant Biggs, Sitsofe Wheeler and nfox18212
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.
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)
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?
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. ;)
Activity
tianon commentedon Feb 10, 2014
This is definitely not a reasonable default, and setting it via
ENVshould 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 viaENV(ie,RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq ...).SvenDowideit commentedon Feb 10, 2014
/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 everyapt-getline 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
ENVset it at the top, and thenENVunset it after?SvenDowideit commentedon Feb 14, 2014
closed by #4035
pmorch commentedon Jun 15, 2014
I saw the note in the docs that
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?Seems to be the way to do it. @SvenDowideit hints at:
But is it possible to "then ENV unset it after"? A single-arg:
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...
czerasz commentedon Jul 28, 2014
@pmorch You could just set it to it's default value
Resource link
shaunc commentedon Mar 29, 2015
Maybe there should be a BUILDENV command that just sets environment during build :)
duglin commentedon Mar 29, 2015
hmmm #9176 :-)
Set environment variables inline
ENV DEBIAN_FRONTEND will persist and is not recommended, as per
drastik commentedon Dec 10, 2015
What is the consensus on the best practice here?
thaJeztah commentedon Dec 10, 2015
@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 packageshould workOnly set DEBIAN_FRONTEND during build
markriggins commentedon Mar 4, 2016
The new ARG directive in the Dockerfile can set this only during the build
ARG DEBIAN_FRONTEND=noninteractive36 remaining items
Dockerfile: use ARG not ENV for DEBIAN_FRONTEND
Set build time options for dpkg and reproducible builds
Setting DEBIAN_FRONTEND to noninteractive via ARG instead of ENV.
🛹 Set DEBIAN_FRONTEND=noninteractive on-the-fly
fix: setting DEBIAN_FRONTEND as a Docker ARG
tianon commentedon Mar 19, 2024
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_FRONTENDshouldn't be necessary in any cases anymore in recent releases of those distributions.Revisit usage of DEBIAN_FRONTEND=noninteractive.
rgov commentedon Oct 22, 2024
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=readlineto error out if there's no controlling TTY, right? This patch doesn't implicitly switch tononinteractive.tianon commentedon Oct 23, 2024
It makes the frontend error out, not the
apt-get install, so here's how that plays out in practice:(ie, the end result is
DEBIAN_FRONTEND=teletype, which should "just work" appropriately)revert persistent noninteractive DEBIAN_FRONTEND
nfox18212 commentedon Mar 11, 2025
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?
Or should I use the ARG directive? As in
and then the environment variable will automatically be unset after build, so any RUN directive I use to install packages will just work?
theAkito commentedon Mar 11, 2025
If you would need to set the environment variable, this wouldn't work with an
ARG, if the image did not specifically handle thatARG, 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. ;)
Use ARG instead of ENV to set DEBIAN_FRONTEND
DEBIAN_FRONTEND - moby/moby#4032
Set build time options for dpkg and reproducible builds