How to add a comment in a Dockerfile

617    Asked by TeresaMorris in Python , Asked on Apr 24, 2021

I have created Dockerfile and I wanted to know that how to add dockerfile comments? Is there any way in docker which allows adding a comment option that takes the rest of a line and ignores it?

Answered by Ranjana Admin

You can try using # and it will treat the whole line as a comment in your docker file.

For example:

  # Everything on this line is a comment

Note: Format. Docker treats lines that begin with # as a comment unless the line is a valid parser directive. A # marker anywhere else in a line is treated as an argument.



Your Answer

Interviews

Parent Categories