Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (2.3k points)

So I was wondering if I could write comments in a Docker file, Is there a way to do it?

1 Answer

0 votes
by (6.9k points)

According to the official docker documentation 

Everything that follows a # is considered as a comment inside of dockerfile.

Example :

# Everything on this line is a comment but it can be used only in the begining of the line

NOTE : There is something called a parser directive recently added and it shares it syntax with comments. So to differentiate between the both, parser directives need to be on top of the file before any commands or comments.

Example :

# escape=`

FROM microsoft/nanoserver
COPY testfile.txt c:\ 
RUN dir c:\ 

Hope this helps :)

Docker Training course can be very useful for anyone who is looking to get a job in the DevOps field. 

Related questions

Browse Categories