2016-04-19 9 views

答えて

0

Dockerfileコメントは、Pythonと同様に「#」で始まります。 https://github.com/kstaken/dockerfile-examples/blob/master/mongodb/Dockerfile

# Install a more up to date 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"] 
14

使用からのコメント

ため#構文::他の人が述べたようにhttps://docs.docker.com/engine/reference/builder/#format

# My comment here 
RUN echo 'we are running some cool things' 
+1

私はRUN、COPY、MAINTAINERなどと同じ行にコメントできますか? –

+0

@AlexanderMillsはい私はインラインコメントにリンクされている文書は有効な 'ADDです。 $ foo#ADD。 /バー ' – edhurtig

14

、コメントは#で参照しているがdocumented hereをしている。ここ は良い例です。 。ただし、一部の言語とは異なり、#は行の先頭にある必要があります。行の途中で発生した場合、それらは引数として解釈され、予期しない動作が発生する可能性があります。

# This is a comment 

COPY test_dir target_dir # this is not a comment, it is an arg to COPY 

RUN echo hello world # this is an argument to RUN but the shell may ignore it 

またparser directives最近のコメントと同じ構文を持つDockerfileに追加されていることに留意すべきです。他のコメントやコマンドの前に、ファイルの先頭に表示する必要があります。 、最初の行

# escape=` 

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

それはコメントのように見える一方で、パーサディレクティブは、なるようにバッククォートをエスケープ文字を変更することです:現時点では、唯一のディレクティブは、Windowsをサポートするためのエスケープ文字を変更するためのものですCOPYおよびRUNコマンドでは、パスにバックスラッシュを使用できます。

関連する問題