Browse code

remove references to 'source repository'

- rewrite intro to Dockerfile reference usage section to remove
references to 'source repository'
- Closes #14714
- Fixes: #8648
- Updating with Seb's comments

Signed-off-by: Mary Anthony <mary@docker.com>

Morgan Bauer authored on 2015/07/18 03:40:56
Showing 1 changed files
... ...
@@ -10,48 +10,50 @@ parent = "mn_reference"
10 10
 
11 11
 # Dockerfile reference
12 12
 
13
-**Docker can build images automatically** by reading the instructions
14
-from a `Dockerfile`. A `Dockerfile` is a text document that contains all
15
-the commands you would normally execute manually in order to build a
16
-Docker image. By calling `docker build` from your terminal, you can have
17
-Docker build your image step by step, executing the instructions
18
-successively.
19
-
20
-This page discusses the specifics of all the instructions you can use in your
21
-`Dockerfile`. To further help you write a clear, readable, maintainable
22
-`Dockerfile`, we've also written a [`Dockerfile` Best Practices
23
-guide](/articles/dockerfile_best-practices). Lastly, you can test your
24
-Dockerfile knowledge with the [Dockerfile tutorial](/userguide/level1).
13
+Docker can build images automatically by reading the instructions from a
14
+`Dockerfile`. A `Dockerfile` is a text document that contains all the commands a
15
+user could call on the command line to assemble an image. Using `docker build`
16
+users can create an automated build that executes several command-line
17
+instructions in succession.
18
+
19
+This page describes the commands you can use in a `Dockerfile`. When you are
20
+done reading this page, refer to the [`Dockerfile` Best
21
+Practices](/articles/dockerfile_best-practices) for a tip-oriented guide.
25 22
 
26 23
 ## Usage
27 24
 
28
-To [*build*](/reference/commandline/build) an image from a source repository,
29
-create a description file called `Dockerfile` at the root of your repository.
30
-This file will describe the steps to assemble the image.
25
+The [`docker build`](/reference/commandline/build/) command builds an image from
26
+a `Dockerfile` and a *context*. The build's context is the files at a specified
27
+location `PATH` or `URL`. The `PATH` is a directory on your local filesystem.
28
+The `URL` is a the location of a Git repository.
31 29
 
32
-Then call `docker build` with the path of your source repository as the argument
33
-(for example, `.`):
30
+A context is processed recursively. So, a `PATH` includes any subdirectories and
31
+the `URL` includes the repository and its submodules. A simple build command
32
+that uses the current directory as context:
34 33
 
35 34
     $ docker build .
35
+    Sending build context to Docker daemon  6.51 MB
36
+    ...
37
+
38
+The build is run by the Docker daemon, not by the CLI. The first thing a build
39
+process does is send the entire context (recursively) to the daemon.  In most
40
+cases, it's best to start with an empty directory as context and keep your
41
+Dockerfile in that directory. Add only the files needed for building the
42
+Dockerfile.
43
+
44
+>**Warning**: Do not use your root directory, `/`, as the `PATH` as it causes
45
+>the build to transfer the entire contents of your hard drive to the Docker
46
+>daemon. 
47
+
48
+To use a file in the build context, the `Dockerfile` refers to the file with
49
+an instruction, for example,  a `COPY` instruction. To increase the build's
50
+performance, exclude files and directories by adding a `.dockerignore` file to
51
+the context directory.  For information about how to [create a `.dockerignore`
52
+file](#dockerignore-file) see the documentation on this page.
36 53
 
37
-The path to the source repository defines where to find the *context* of
38
-the build. The build is run by the Docker daemon, not by the CLI, so the
39
-whole context must be transferred to the daemon. The Docker CLI reports
40
-"Sending build context to Docker daemon" when the context is sent to the daemon.
41
-
42
-> **Warning**
43
-> Avoid using your root directory, `/`, as the root of the source repository. The 
44
-> `docker build` command will use whatever directory contains the Dockerfile as the build
45
-> context (including all of its subdirectories). The build context will be sent to the
46
-> Docker daemon before building the image, which means if you use `/` as the source
47
-> repository, the entire contents of your hard drive will get sent to the daemon (and
48
-> thus to the machine running the daemon). You probably don't want that.
49
-
50
-In most cases, it's best to put each Dockerfile in an empty directory. Then,
51
-only add the files needed for building the Dockerfile to the directory. To
52
-increase the build's performance, you can exclude files and directories by
53
-adding a `.dockerignore` file to the directory.  For information about how to
54
-[create a `.dockerignore` file](#dockerignore-file) on this page.
54
+Traditionally, the `Dockerfile` is called `Dockerfile` and located in the root
55
+of the context. You use the `-f` flag with `docker build` to point to a Dockerfile
56
+anywhere in your file system.
55 57
 
56 58
 You can specify a repository and tag at which to save the new image if
57 59
 the build succeeds:
... ...
@@ -166,13 +168,13 @@ as well as:
166 166
 > variable, even when combined with any of the instructions listed above.
167 167
 
168 168
 Environment variable substitution will use the same value for each variable
169
-throughout the entire command.  In other words, in this example:
169
+throughout the entire command. In other words, in this example:
170 170
 
171 171
     ENV abc=hello
172 172
     ENV abc=bye def=$abc
173 173
     ENV ghi=$abc
174 174
 
175
-will result in `def` having a value of `hello`, not `bye`.  However, 
175
+will result in `def` having a value of `hello`, not `bye`. However, 
176 176
 `ghi` will have a value of `bye` because it is not part of the same command
177 177
 that set `abc` to `bye`.
178 178
 
... ...
@@ -191,7 +193,7 @@ expansion) is done using Go's
191 191
 
192 192
 You can specify exceptions to exclusion rules. To do this, simply prefix a
193 193
 pattern with an `!` (exclamation mark) in the same way you would in a
194
-`.gitignore` file.  Currently there is no support for regular expressions.
194
+`.gitignore` file. Currently there is no support for regular expressions.
195 195
 Formats like `[^temp*]` are ignored. 
196 196
 
197 197
 The following is an example `.dockerignore` file:
... ...
@@ -310,7 +312,7 @@ commands using a base image that does not contain `/bin/sh`.
310 310
 
311 311
 The cache for `RUN` instructions isn't invalidated automatically during
312 312
 the next build. The cache for an instruction like 
313
-`RUN apt-get dist-upgrade -y` will be reused during the next build.  The 
313
+`RUN apt-get dist-upgrade -y` will be reused during the next build. The 
314 314
 cache for `RUN` instructions can be invalidated by using the `--no-cache` 
315 315
 flag, for example `docker build --no-cache`.
316 316
 
... ...
@@ -888,7 +890,7 @@ The `VOLUME` instruction creates a mount point with the specified name
888 888
 and marks it as holding externally mounted volumes from native host or other
889 889
 containers. The value can be a JSON array, `VOLUME ["/var/log/"]`, or a plain
890 890
 string with multiple arguments, such as `VOLUME /var/log` or `VOLUME /var/log
891
-/var/db`.  For more information/examples and mounting instructions via the
891
+/var/db`. For more information/examples and mounting instructions via the
892 892
 Docker client, refer to 
893 893
 [*Share Directories via Volumes*](/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume)
894 894
 documentation.