-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Allow Heredoc (or multi line instructions) in RUN command (in Dockerfile) #1554
Comments
To focus on your specific example: it might make more sense to commit your config & dockerfile to a git or mercurial repository, and ADD the config file during the build.
On Thu, Aug 15, 2013 at 7:59 AM, Brikou CARRE notifications@github.com
|
I'm closing this in favor of #1799. If you think this issue should be re-opened, please re-open it or ask me to do it. |
The problem with using a separate file + ADD is that it will be cached, so you can't tweak what would have been in the heredoc. You have to completely avoid caching everything that comes before the multi-line part. If you actually want to use heredoc, as is really common in the case of the pattern: cat > /etc/some/file.conf <<'EOF'
Whatever multi-line stuff
I need to put here
without any headaches
EOF Then using the |
ADD does cache though, for several versions now |
Yes, that is a problem. I want to be able to edit the file and have docker do "smart" caching. If the string that is in this file was part of a command, docker would understand it can't use the cache. But put it in a file and suddenly the cache effectively makes the file immutable, unless you completely go around the caching, which in my case (entire llvm toolchain) I don't want to do. |
Previously, ADD was just always a cache bust, but now it is as you might expect, busting based on a checksum of what was added, so changing the file will cause a natural cache bust as you might expect. |
+1 here |
+1 ! |
+10000000 |
How can I run something from a user different from the root user when building new image ? |
@PositiveAlex You can use |
@unclejack thank you, and sorry, I should read manual more accurate first... |
No Heredoc and a little ugly but it work ...
+1 Heredoc |
USER POLL The best way to get notified when there are changes in this discussion is by clicking the Subscribe button in the top right. The people listed below have appreciated your meaningfull discussion with a random +1: @sleaze |
+1 |
Would definitely be interested in seeing this as well! 👍 |
Also see this comment; #16058 (comment) |
+1 for Heredoc |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
Stop posting +1, use the new GitHub reactions feature. |
+1 Thank you! So glad and happy this got implemented! |
@cjac You referenced an old PR which implemented the |
Oh :/ sad now |
Heredoc is awesome for writing small script/config, etc. I don't care what's cache it or not. |
👍 This should be implemented! |
+1 just to piss off @GordonTheTurtle |
This thread is a bit dated now but I still haven't found native support for this. Anyhoo, in case it helps someone else what I do is pull alpine, add in coreutils as a virtual-dep, move base64 to /usr/local/bin and in my Dockerfile, RUN echo "" | base64 --decode > /etc/myconf.conf so it will copy over my base configs. Supports line breaks in the encoded form so no mess (if you consider this non-messy). Extra points if you use envsubst (add as virtual-dep like above, then move before deleting the large unnecessary packages) to mod the config file with your ENV variables. I just really hate extra files hanging around. |
One possible workaround is the following:
Prefix everything with |
+1 BUMP still waiting on this one ...... Cheerio |
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@unclejack 5 years ago you told me you can reopen? Can you? |
There is a new issue / proposal that I linked to; #34423. Please continue the conversation over there (also, please don't add |
@thaJeztah your proposal is nice but really not the same as not dealing with shell heredoc. |
@brikou I think it should allow you to do that, e.g. something like this; RUN <<EOF
cat > /etc/my.config <<EOM
########################################################
# The file
########################################################
a = b
EOM
EOF |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Locking the conversation on this issue in favor of #34423. Please continue the conversation over there (also, please don't add |
An interesting use case would be to patch config file within dockerfile
The text was updated successfully, but these errors were encountered: