Add support for ENV of the form: ENV name=value ...#8251
Add support for ENV of the form: ENV name=value ...#8251crosbymichael merged 1 commit intomoby:masterfrom
Conversation
docs/sources/reference/builder.md
Outdated
There was a problem hiding this comment.
how about the entire string after the first space will be treated as the <value>?
There was a problem hiding this comment.
Changed per your suggestion.
docs/sources/reference/builder.md
Outdated
There was a problem hiding this comment.
I've just tested (using make docs) and these indented code sections need an extra line feed:
For example:
ENV myName="John Doe" myDog=Rex\ The\ Dog
and
ENV myName John Doe
ENV myDog Rex The Dog
will yield the same net results in the final container, but the first form
does it all in one layer.
|
Docs LGTM |
docs/sources/reference/builder.md
Outdated
There was a problem hiding this comment.
I assume you meant that I needed to add single-back-quotes around it, if so, done. If not, can you elaborate?
|
Docs LGTM. |
|
I don't exactly understand why this is necessary though. |
|
@erikh ? |
|
I think solomon needs to weigh in on this before we can merge it. As for the feature, it could reduce layers, so I’m all for it. On Sep 26, 2014, at 1:55 PM, Jessie Frazelle [email protected] wrote:
|
|
If I understand this correctly, it would reduce the number of layers produced, so for that, I'm +1, but possibly an improved builder could automatically optimise this? Multiple edit |
|
Yep, as I mentioned, I have mixed feelings and am ok either way we go - as long as we come to a decision and close the original issue. To @thaJeztah's comment... yep, multiple ENVs are easier, but with this you can write: @shykes - any thoughts on this one? |
Well, I think that points to the underlying problem. In the current implementation of the Dockerfile / builder, users have to "jump through hoops" to make docker do what they intended, or to optimise the results (reduce layers and/or reduce image-size). In some cases, this results in "mangling" a perfectly readable Dockerfile into something that's hard to grasp, just for the sake of optimisation. In short, even though I want this functionality (for optimisation), if there's a chance that the builder is able to optimise this automatically in the short future, I'm hesitant to introduce a new syntax as a stop-gap solution. If such optimisation will not be possibly in the foreseeable future, OR this syntax has other advantages that I'm overseeing, then it's fine with me. note @erikh since you did the last major rewrite of the builder/parser, do you know if such issue already exists? Should one be created? |
|
Docs LGTM and thanks for the contribution. |
|
I think the design and UI looks good. We wanted the feature, we just did not like using the json syntax for it. |
|
How do we decide if we want to move forward with this? |
|
@crosbymichael thoughts? |
|
I don't object to it; we're kicking out a 1.3.1 probably today with some builder fixes. Can we wait until after that? |
|
Oh and this needs a rebase. |
|
@erikh - rebase is done! |
|
Thanks Doug. Ping me on IRC if I don’t get to this in the next few days, please.
|
|
So, looking at this again, I would like to ask for a few things:
|
|
We need one more maintainer LGTM -- that means @tiborvass or @crosbymichael |
|
@tiborvass @crosbymichael any comments? |
|
It would be nice to have this available on cli arguments not just within a Dockerfile. At the moment when I set an env variable as |
|
@milosgajdos83 normally the cmd line processing would do the right thing. For me I don't see quotes: $ docker run -ti -e foo="bar" ubuntu env |
|
What shells are you two using? -Erik
|
|
I get the same results from bash and sh. |
|
Same result on zsh 5 here.
|
There was a problem hiding this comment.
maybe add a third example with ENV <key1>=<value1> <key2>=<value2> ?
There was a problem hiding this comment.
line 357 isn't good enough?
There was a problem hiding this comment.
It's good as well, but since this is right after the ENV title, it seems to me, it's a general template of what's possible with the keyword. Line 357 goes into even more detail with quotes. Anyway, it was just a suggestion. I guess docs people are better suited to answer this.
There was a problem hiding this comment.
actually I was about to add it (just for you :-) ) but then I realized, isn't the ... in there good enough since it means "repeat the last thing" ? If I added:
ENV = <key2=value2> ...
people might wonder what the difference is between that line and the previous one. And are we really saying we have a special syntax where we specify two or more and not just one or more?
At least my interpretation of that chunk of docs is that its not a sample but more like a pseudo-schema of what's expected. But I could be wrong.
There was a problem hiding this comment.
Oh yeah maybe that's sufficient then :) If we don't hear from the docs guys about this issue, then let's just leave it.
|
ok I think I got all of @tiborvass 's suggested changes pushed now. |
still supports the old form: ENV name value Also, fixed an issue with the parser where it would ignore lines at the end of the Dockerfile that ended with \ Closes moby#2333 Signed-off-by: Doug Davis <[email protected]>
|
LGTM |
Add support for ENV of the form: ENV name=value ...
still supports the old form: ENV name value.
Notes:
since shells support:
abc=123 def=456
I think supporting:
ENV abc=123 def=456
makes a lot of sense. This isn't just about doing some kind of batching (which is being worked on in other PRs), this aligns ENV with what shells supports.
Keeping old description for posterity:
I have mixed feelings about this. While it works and is kind of cool to be able to do:
ENV abc=def foo="feed the dog" hungry=eat\ a\ pizza late="go to bed 'now' I said"
and each key=value is parsed like you'd expect it to be on the command line, the ability to do more than
one ENV at a time really should be done under some kind of batching mechanism. But, of course,
that's not there yet and we're not sure when it will be. So, unlike the RUN command where we can
concat things together with &&'s, the ENV command doesn't have that option - not without this feature.
Closes #2333
Signed-off-by: Doug Davis [email protected]