diff --git a/docs/reference/builder.md b/docs/reference/builder.md index 6217d0d341..9635bddfa9 100644 --- a/docs/reference/builder.md +++ b/docs/reference/builder.md @@ -115,11 +115,11 @@ The instruction is not case-sensitive. However, convention is for them to be UPPERCASE to distinguish them from arguments more easily. -Docker runs instructions in a `Dockerfile` in order. **The first +Docker runs instructions in a `Dockerfile` in order. **The first instruction must be \`FROM\`** in order to specify the [*Base -Image*](glossary.md#base-image) from which you are building. +Image*](glossary.md#base-image) from which you are building. -Docker treats lines that *begin* with `#` as a comment, unless the line is +Docker treats lines that *begin* with `#` as a comment, unless the line is a valid [parser directive](builder.md#parser directives). A `#` marker anywhere else in a line is treated as an argument. This allows statements like: @@ -132,20 +132,20 @@ Line continuation characters are not supported in comments. ## Parser directives -Parser directives are optional, and affect the way in which subsequent lines +Parser directives are optional, and affect the way in which subsequent lines in a `Dockerfile` are handled. Parser directives do not add layers to the build, and will not be shown as a build step. Parser directives are written as a special type of comment in the form `# directive=value`. A single directive may only be used once. -Once a comment, empty line or builder instruction has been processed, Docker +Once a comment, empty line or builder instruction has been processed, Docker no longer looks for parser directives. Instead it treats anything formatted as a parser directive as a comment and does not attempt to validate if it might be a parser directive. Therefore, all parser directives must be at the very -top of a `Dockerfile`. +top of a `Dockerfile`. Parser directives are not case-sensitive. However, convention is for them to -be lowercase. Convention is also to include a blank line following any +be lowercase. Convention is also to include a blank line following any parser directives. Line continuation characters are not supported in parser directives. @@ -166,7 +166,7 @@ Invalid due to appearing twice: FROM ImageName ``` - + Treated as a comment due to appearing after a builder instruction: ```Dockerfile @@ -190,10 +190,10 @@ a comment which is not a parser directive. ```Dockerfile # unknowndirective=value # knowndirective=value -``` - +``` + Non line-breaking whitespace is permitted in a parser directive. Hence, the -following lines are all treated identically: +following lines are all treated identically: ```Dockerfile #directive=value @@ -215,26 +215,26 @@ Or # escape=` (backtick) -The `escape` directive sets the character used to escape characters in a -`Dockerfile`. If not specified, the default escape character is `\`. +The `escape` directive sets the character used to escape characters in a +`Dockerfile`. If not specified, the default escape character is `\`. The escape character is used both to escape characters in a line, and to escape a newline. This allows a `Dockerfile` instruction to span multiple lines. Note that regardless of whether the `escape` parser -directive is included in a `Dockerfile`, *escaping is not performed in -a `RUN` command, except at the end of a line.* +directive is included in a `Dockerfile`, *escaping is not performed in +a `RUN` command, except at the end of a line.* -Setting the escape character to `` ` `` is especially useful on -`Windows`, where `\` is the directory path separator. `` ` `` is consistent +Setting the escape character to `` ` `` is especially useful on +`Windows`, where `\` is the directory path separator. `` ` `` is consistent with [Windows PowerShell](https://technet.microsoft.com/en-us/library/hh847755.aspx). -Consider the following example which would fail in a non-obvious way on +Consider the following example which would fail in a non-obvious way on `Windows`. The second `\` at the end of the second line would be interpreted as an -escape for the newline, instead of a target of the escape from the first `\`. +escape for the newline, instead of a target of the escape from the first `\`. Similarly, the `\` at the end of the third line would, assuming it was actually handled as an instruction, cause it be treated as a line continuation. The result of this dockerfile is that second and third lines are considered a single -instruction: +instruction: ```Dockerfile FROM windowsservercore @@ -250,18 +250,18 @@ Results in: ---> dbfee88ee9fd Step 2 : COPY testfile.txt c:RUN dir c: GetFileAttributesEx c:RUN: The system cannot find the file specified. - PS C:\John> + PS C:\John> One solution to the above would be to use `/` as the target of both the `COPY` instruction, and `dir`. However, this syntax is, at best, confusing as it is not natural for paths on `Windows`, and at worst, error prone as not all commands on `Windows` support `/` as the path separator. -By adding the `escape` parser directive, the following `Dockerfile` succeeds as +By adding the `escape` parser directive, the following `Dockerfile` succeeds as expected with the use of natural platform semantics for file paths on `Windows`: # escape=` - + FROM windowsservercore COPY testfile.txt c:\ RUN dir c:\ @@ -279,9 +279,9 @@ Results in: ---> Running in a5ff53ad6323 Volume in drive C has no label. Volume Serial Number is 1440-27FA - + Directory of c:\ - + 03/25/2016 05:28 AM