How to Add a Comments in Dockerfile

Channel: Linux
Abstract: # This is a comment lineunless the line is a valid directive. The # marker must be the first character of of line be make it comments

Comments are the important parts of any programming language. Which is used to describe details about the application. In this tutorial you will learn about using comments in Dockerfile.

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:

# This is a comment line
RUN echo 'Welcome to tecadmin.net'

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.

Ref From: tecadmin

Related articles