-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser in docker 1.13 breaks backwards compatibility for comments in middle of RUN statement #29005
Comments
Just for reference, #28587 was another issue discussing this, but I think at least the comment half of this change is a really serious regression (and is going to be a pretty severe breaking change for existing |
The last-known version where comments were not supported inline being 1.5 is amusing given https://blog.docker.com/2015/10/docker-hub-deprecation-1-5/ (1.5 and earlier no longer supported by Docker Hub 😄) |
Any way we could do some querying on the public automated builds to see at least in the public aspect what the impact of this breaking change is? |
This fix is to address moby#29005 where continuation after comments are not allowed after moby#24725. This fix made the change so that moby#29005 could be addressed. An integration test has been added. Other related tests have been udpated to conform to the behavior changes. This fix fixes moby#29005, but please feel free for any additional suggestions. Signed-off-by: Yong Tang <[email protected]>
It also affects me. So there is no deprecation policy? Great. |
@davidfischer-ch yes, it has been overlooked 😓 😞. We are gonna work on it for the 1.13.0 GA so it does not break people |
There's a couple of issues at hand here; I think the original design for While this should probably be "true", the implementation does not match that;
Because of these steps, a Basically, comment-only lines are handled by Docker, comments preceeded by Note that skipping comments not starting at position PR #24725 was created to fix cases where, FROM busybox
RUN echo "foo" \
#&& echo "bar";
# Do something else
RUN echo "something else" Resulting in;
I think we should fix that case, but we can consider it a "legacy" burden A. Revert all changesInclude both empty and comment lines as part of the FROM busybox
RUN echo "foo"; \
# This is a comment
# So is this
echo "and this is part of the same RUN"
RUN echo "this is the next RUN" B. Skip comment-only lines, but break on empty linesThis is what's being implemented in #29006. Users can use a With this change, this would still be valid; FROM busybox
RUN echo "foo"; \
\
# This is a comment
\
# So is this
\
echo "and this is part of the same RUN"
RUN echo "this is the next RUN" C. Skip comment-only lines, warn / deprecate continuing on empty linesLike |
High-order question (IMO): If we were starting from scratch would we want it to act like the shell does? Meaning, stop when it hits a blank line AND when it hits a comment? In a perfect world I'd say "yes". Which would then lead towards us deprecating the new behavior and then removing it in 3 releases. However, there's a catch. Not only do we have a lot of Dockerfiles in the wild with this "odd" syntax (which by itself doesn't necessarily mean we should allow it to continue), BUT given there's no good way to prevent multiple layers from being created when you have multiple RUNs, which means people are kind of forced into using RUNs that span a lot of lines via continuation chars, there's no good way to allow people to be good citizens and add comments/docs to their long RUN cmds. Now, if we had a "squash just certain layers" type of operation in Dockerfiles then people wouldn't need to create these huge RUN cmds. They could have multiple RUNs, with comments between them, and then squash them down afterwards. Normally, in the past, we tried to align Dockerfile processing with shell processing, but this point (to me) is why we may not be able to align with the shell in this case. Net: I think we should add back in support for comments in multi-line cmds but don't deprecate it until (or 'if') we add support for selective squashing. |
@thaJeztah @duglin From my understanding, the issue we are facing now is probably not about when to continue for For example, let's assume there is another command pair
Then the above will be much cleaner and a lot easier to parse, because we could essentially cut any blob in between We could even add an additional flag to specify which shell, e.g.,
I think another alternative solution is to revert back the old behavior, while at the same time introduce a new command pair At the same time, we encourage users to use I don't know if introducing another (pair) command for Dockerfile is the best solution. But to be honest, |
Yea, a heredoc is another option. For now I think the current PR is the right approach - we can then decide on the rest later. |
@tianon I know it was done at some point, i.e. every Dockerfile on GitHub was built/tested for a change that was made in the builder. I'm not sure how it was done though; @crosbymichael may know |
My own vote would be C, given that blank lines are trivially fixed by adding a |
My preference is A for Docker 1.13. B breaks all Dockerfiles (30+) in my team, and I suspect may impact many others. I believe such a significant breaking change should be communicated three releases in advance, as stated in Breaking changes and incompatibilities. As for C, while blank lines are trivially fixed by adding a |
Oh sorry, I misspoke -- my preference is for C, but I'd be fine with A. I think B is a bit too aggressive on the breakage scale for 1.13 alone. |
My preference goes to C, but with an extra note; let's see if we can find a better solution before 1.16 (such as the discussed heredoc/code-block). We can extend the deprecation period if needed if no alternative is present yet. |
For 1.13 I'd go for A. |
So, let's go for A for 1.13 (see #29064) and work on C afterwars. |
Just ran into this new feature. I have to say, solution C for 1.13 seems more reasonable. |
@NicoTexas Added a PR #29161 for solution C. The PR generates a warning for empty line continuation, for 1.14 (maybe). |
@duglin #29005 (comment) the other reason for |
According moby issue, it will be forbidden to inset comment in between multiline commands moby/moby#29005
Description
Previously (Docker 1.6+) one could document long
RUN
lines with comments interspersed. #24725 broke this.Steps to reproduce the issue:
Describe the results you received:
Error response from daemon: Unknown instruction: HI
Describe the results you expected:
Docker build the above Dockerfile on 1.6 through 1.12 (thanks @tianon for testing all of them)
Successfully built xxx
Additional information you deem important (e.g. issue happens only occasionally):
Quick list of some official-images broken by this change:
Output of
docker version
:(working version)
Output of
docker info
:(working version)
The text was updated successfully, but these errors were encountered: