Dockerfile is a text file that contains a set of DOCKER commands Dockerfile contains comments to describe the line of commands.
Comments are written using a line that starts with the #
symbol followed by a comment string.
So Docker treats the lines that start with #
.
Placing this symbol on part of the line is considered an argument, not a comment.
It supports single-line comments only.
How to write comments in Docker
Docker comments start with the #
symbol followed by the comment string.
It supports Single level comments
Here is an example
# comment example
RUN echo 'Print this'
Symbol #
placed in line other beginning, It treats as a Docker command.
Below example, # not supported
is not a comment, but the command run echo used to print to the console.
# comment example
RUN echo 'Print this' # not supported
Docker Multiline comments
There is no syntax to support the /* */
syntax in Dockerfile.
You can use single-line comments that start with #
and comments.
Visual studio codes support shortcuts to comment on multiple lines.
# image configuration
# node image with version 15 to pick
FROM node:15.0
# comment example
RUN echo 'Print this' # not supported