How can I add comments in long docker RUN commands?
You need to have a line with only the comment:
# comment 1
RUN apt-get update \
# comment 2
&& apt-get install blabal blabla blabla \
# comment 3
&& echo this is not a drill
docker removes the comment line with the newline.
See docker-nginx with examples.
If you want comments on the same line as the commands, you can use this syntax:
RUN apt-get update -y `# comment1` \
&& apt-get install -y `# comment2` \
software-properties-common `# comment3` \
curl `# comment4`
or
RUN apt-get update -y $(: comment1) \
&& apt-get install -y $(: comment2) \
software-properties-common $(: comment3) \
curl $(: comment4)