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
{{ message }}
Repository navigation
dockerfile specification for unsetting environment variables. #9298
I want to be able to have a default setting for environment variables in my Dockerfile that cause the env value for a value to not be set when you don't pass --env. Can ENV be improved to support this or give ENV a way to specify an empty string?
case 1 :
ENV foo "" will result in a bash test like if [ -z $ENV ] ; to be false. this is because the value for foo is actually being stored as '""'
Please provide some syntax so that [ -z $FOO ] can be true.
Thanks!
Reacted by Franz Josef Kaiser, Michal Kočárek, JeremyCraigMartinez, Miguel Rasero Peral, Asfand Qazi, Christopher Dignam, nuarhu and Andy Hayden
What if you leave out the ENV entirely? Or has the ENV already been defined in the image you're using as FROM? Perhaps these might be interesting for your case; #3465 and #8177
UNSET seems like it could help for the case of inheritance, i like that, but in my dockerfile i want to communicate the intent of a default value that can be overridden at run time with a --env option from whats provided in the Dockerfile. In this case the default I want is an empty string but empty string values don't seem to evaluate correctly in bash.
Will UNSET still list the variables being managed in the Dockerfile at the command line?
Unset will (as proposed, it's not yet merged), basically "remove" the ENV declaration. However, in your case, I'd really just remove the ENV and describe in the README.md that people are able to set an environment variable via -e FOOBAR. If the only reason for adding it to the Dockerfile is to "document" the variable, you could always add a comment line?
Could we consider reopening this, in light of #3465 being closed?
My specific usecase is needing to set a specific environment variable (DEBIAN_FRONTEND=noninteractive) for a number of RUN statements, and having them all say that is an awful lot of cruft instead of the ability to delete the environment variable.
(Syntaxwise, I imagine ENV !DEBIAN_FRONTEND to be clean, but I don't really care..)
related and discusses specific need: ... ENV DEBIAN_FRONTEND nointeractive #9176#4032
@duglin it may or may not help in this specific case (I have no idea what setting DEBIAN_FRONTEND to the empty string has). But in general, we would like the ability to return the environment to the state we found it. With DEBIAN_FRONTEND not set.
I have a mandatory requirement for UNSET - you see, the silly upstreamers set an environment variable which breaks my builds, and setting it to empty string (ENV FOO=) does not work - it HAS to not be defined for my build to work the way I want without ugly kludges. So......
+1
Reacted by Martyn Cross, Larry Grill, Bill Wang, Zaar Hai, Joe Bowbeer and Michał Zawiślak
Activity
thaJeztah commentedon Nov 23, 2014
What if you leave out the
ENVentirely? Or has the ENV already been defined in the image you're using asFROM? Perhaps these might be interesting for your case; #3465 and #8177sfc-gh-eraigosa commentedon Nov 23, 2014
UNSET seems like it could help for the case of inheritance, i like that, but in my dockerfile i want to communicate the intent of a default value that can be overridden at run time with a --env option from whats provided in the Dockerfile. In this case the default I want is an empty string but empty string values don't seem to evaluate correctly in bash.
Will UNSET still list the variables being managed in the Dockerfile at the command line?
thaJeztah commentedon Nov 23, 2014
Unset will (as proposed, it's not yet merged), basically "remove" the
ENVdeclaration. However, in your case, I'd really just remove theENVand describe in theREADME.mdthat people are able to set an environment variable via-e FOOBAR. If the only reason for adding it to the Dockerfile is to "document" the variable, you could always add a comment line?If you need more help, perhaps it's better to ask for support on IRC or Google Groups, because the GitHub issue tracker is not the best place for support questions. You can find them on this page; https://docker.com/resources/help/
sfc-gh-eraigosa commentedon Nov 24, 2014
@thaJeztah Yep, I agree with that approach. I'll close this and look for UNSET feature.
thaJeztah commentedon Nov 24, 2014
Thanks! And now hope the
UNSETfeature will be merged soon :)oodograss commentedon Jan 19, 2015
+1 for UNSET
nisaacson commentedon Feb 5, 2015
+1
lavie commentedon Feb 16, 2015
+2!
vlad-belogrudov commentedon Feb 20, 2015
+1 sometimes it is mandatory, e.g. when developing container behind proxy
thaJeztah commentedon Feb 20, 2015
For everyone adding +1's here;
This issue is closed, in favor of #3465, which is still open. There's a pull-request to implement that here; #8177
Please use the other issue to comment, not this one.
scraperdragon commentedon Apr 30, 2015
@thaJeztah @wenlock
Could we consider reopening this, in light of #3465 being closed?
My specific usecase is needing to set a specific environment variable (
DEBIAN_FRONTEND=noninteractive) for a number of RUN statements, and having them all say that is an awful lot of cruft instead of the ability to delete the environment variable.(Syntaxwise, I imagine
ENV !DEBIAN_FRONTENDto be clean, but I don't really care..)related and discusses specific need: ... ENV DEBIAN_FRONTEND nointeractive
#9176#4032duglin commentedon Apr 30, 2015
@scraperdragon I know its not the same thing as unsetting it, but would setting the var to "" help?
e.g.
ENV DEBIAN_FRONTEND=drj11 commentedon Apr 30, 2015
@duglin it may or may not help in this specific case (I have no idea what setting
DEBIAN_FRONTENDto the empty string has). But in general, we would like the ability to return the environment to the state we found it. WithDEBIAN_FRONTENDnot set.okfn/messytables@166f89a shows the particular case in point
duglin commentedon Apr 30, 2015
yea I know, was just hoping to might give you some immediate relief
cdd-aix commentedon Aug 22, 2015
Why not
RUN export DEBIAN_FRONTEND=foo ; apt-get foo; apt-get bar; apt-get quf
?
FEATURE: blank global settings should not shadow
yordis commentedon Jun 22, 2016
@thaJeztah does this works with
build-argsbecause I need it if this doesn't happen.P.S: I am confused about it, the
build-argsare only visible from the build process, right?thaJeztah commentedon Jun 24, 2016
@yordis correct, build args are only available during build, however, depending on what unused them for, their value may still end up an image, e.g.
ayqazi commentedon Jun 8, 2018
I have a mandatory requirement for UNSET - you see, the silly upstreamers set an environment variable which breaks my builds, and setting it to empty string (
ENV FOO=) does not work - it HAS to not be defined for my build to work the way I want without ugly kludges. So......+1
haizaar commentedon Nov 30, 2018
Does anyone have an idea is this is going to be implemented anytime soon?
thaJeztah commentedon Dec 2, 2018
@haizaar see #3465 and #3465 (comment)