The Docker treats each line as comment begin with hash (#) sign, unless the line is a valid directive. The # marker must be the first character of of line be make it comments, anywhere else in a line is treated as an argument. The commends can use used as: In the above example # is placed at the beginning of the line. Any where the # symbol in line is used as an arguments.

The Dockerfile also uses a parser directive which is written on first line of the file and begin with a # symbol. That line is also not count as comment.

How to Add a Comments in Dockerfile   TecAdmin - 15