In Dockerfiles, RUN
instruction tend to be extensive and can rapidly become quite long, containing a lot of instruction with
parameters and flags.
In order to keep a good readability and help for future maintenance, it is important to split them into multiple lines.
It is usually a good idea to group elements that belong together on the same lines.
The usage of the operator &&
allows to
chain multiple operators. Also, the default operator \
allows to continue the RUN
instruction on the next line.
Another
way is to use the here documents format, which allows to define multiple instructions together without any chaining operator.