But then example show that it does support `&&`? Why the difference? I pretty much always write
RUN foo && \
bar && \
:
but it seems syntactically identical to the also valid RUN set -e && \
foo ; \
bar ; \
:But then example show that it does support `&&`? Why the difference? I pretty much always write
RUN foo && \
bar && \
:
but it seems syntactically identical to the also valid RUN set -e && \
foo ; \
bar ; \
:I find it more readable and portable.
[1] https://www.docker.com/blog/introduction-to-heredocs-in-dock...
# syntax=docker/dockerfile:1.3-labs
FROM alpine
RUN <<EOF
echo "This is a heredoc example"
echo "It allows multi-line commands"
EOF
Non-meta: Do you happen to know how portable that is across old docker, podman/buildah, kaniko, etc.? I'd like to adopt it but I don't want it to bite me when I'm not running a recent version of literal docker.> Try to make the Dockerfile easy to understand/read. It may be tempting, for the sake of brevity, to put complicated initialization details into a standalone script and merely add a RUN command in the Dockerfile. However, this causes the resulting Dockerfile to be overly opaque, and such Dockerfiles are unlikely to pass review. Instead, it is recommended to put all the commands for initialization into the Dockerfile as appropriate RUN or ENV command combinations. To find good examples, look at the current official images.
if [ foo ] ; then
bar
fi
to if [ foo ]
then
bar
fi
And also format your example to foo
bar
In this type of situation, it becomes a little trickier to disambiguate when I need to add semicolons and a backslash, and when I need to add only backslashes. If you use `&&` -- you have disambiguated the two cases so I can format it.