How do I make a comment in a Dockerfile?

前端 未结 7 1241
悲&欢浪女
悲&欢浪女 2021-01-29 20:21

I am writing a Dockerfile. Is there a way to make comments in this file?

Does Docker have a comment option that takes the rest of a line and ignores it?

7条回答
  •  天命终不由人
    2021-01-29 21:02

    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.

    example code:

    # this line is a comment
    
    RUN echo 'we are running some # of cool things'
    

    Output:

    we are running some # of cool things
    

提交回复
热议问题