How do I make a comment in a Dockerfile?

前端 未结 7 1147
悲&欢浪女
悲&欢浪女 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:01

    Dockerfile comments start with '#', just like Python. Here is a good example (kstaken/dockerfile-examples):

    # Install a more-up-to date version of MongoDB than what is included in the default Ubuntu repositories.
    
    FROM ubuntu
    MAINTAINER Kimbro Staken
    
    RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
    RUN echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list
    RUN apt-get update
    RUN apt-get -y install apt-utils
    RUN apt-get -y install mongodb-10gen
    
    #RUN echo "" >> /etc/mongodb.conf
    
    CMD ["/usr/bin/mongod", "--config", "/etc/mongodb.conf"] 
    

提交回复
热议问题