|
@@ -21,7 +21,7 @@ Practices](../userguide/eng-image/dockerfile_best-practices.md) for a tip-orient
|
|
The [`docker build`](commandline/build.md) command builds an image from
|
|
The [`docker build`](commandline/build.md) command builds an image from
|
|
a `Dockerfile` and a *context*. The build's context is the files at a specified
|
|
a `Dockerfile` and a *context*. The build's context is the files at a specified
|
|
location `PATH` or `URL`. The `PATH` is a directory on your local filesystem.
|
|
location `PATH` or `URL`. The `PATH` is a directory on your local filesystem.
|
|
-The `URL` is a the location of a Git repository.
|
|
|
|
|
|
+The `URL` is a Git repository location.
|
|
|
|
|
|
A context is processed recursively. So, a `PATH` includes any subdirectories and
|
|
A context is processed recursively. So, a `PATH` includes any subdirectories and
|
|
the `URL` includes the repository and its submodules. A simple build command
|
|
the `URL` includes the repository and its submodules. A simple build command
|
|
@@ -504,7 +504,7 @@ default is `/bin/sh -c` on Linux or `cmd /S /C` on Windows)
|
|
- `RUN ["executable", "param1", "param2"]` (*exec* form)
|
|
- `RUN ["executable", "param1", "param2"]` (*exec* form)
|
|
|
|
|
|
The `RUN` instruction will execute any commands in a new layer on top of the
|
|
The `RUN` instruction will execute any commands in a new layer on top of the
|
|
-current image and commit the results. The resulting comitted image will be
|
|
|
|
|
|
+current image and commit the results. The resulting committed image will be
|
|
used for the next step in the `Dockerfile`.
|
|
used for the next step in the `Dockerfile`.
|
|
|
|
|
|
Layering `RUN` instructions and generating commits conforms to the core
|
|
Layering `RUN` instructions and generating commits conforms to the core
|
|
@@ -519,13 +519,15 @@ command.
|
|
|
|
|
|
In the *shell* form you can use a `\` (backslash) to continue a single
|
|
In the *shell* form you can use a `\` (backslash) to continue a single
|
|
RUN instruction onto the next line. For example, consider these two lines:
|
|
RUN instruction onto the next line. For example, consider these two lines:
|
|
|
|
+
|
|
```
|
|
```
|
|
-RUN /bin/bash -c 'source $HOME/.bashrc ;\
|
|
|
|
|
|
+RUN /bin/bash -c 'source $HOME/.bashrc; \
|
|
echo $HOME'
|
|
echo $HOME'
|
|
```
|
|
```
|
|
Together they are equivalent to this single line:
|
|
Together they are equivalent to this single line:
|
|
|
|
+
|
|
```
|
|
```
|
|
-RUN /bin/bash -c 'source $HOME/.bashrc ; echo $HOME'
|
|
|
|
|
|
+RUN /bin/bash -c 'source $HOME/.bashrc; echo $HOME'
|
|
```
|
|
```
|
|
|
|
|
|
> **Note**:
|
|
> **Note**:
|
|
@@ -641,7 +643,7 @@ If the user specifies arguments to `docker run` then they will override the
|
|
default specified in `CMD`.
|
|
default specified in `CMD`.
|
|
|
|
|
|
> **Note**:
|
|
> **Note**:
|
|
-> don't confuse `RUN` with `CMD`. `RUN` actually runs a command and commits
|
|
|
|
|
|
+> Don't confuse `RUN` with `CMD`. `RUN` actually runs a command and commits
|
|
> the result; `CMD` does not execute anything at build time, but specifies
|
|
> the result; `CMD` does not execute anything at build time, but specifies
|
|
> the intended command for the image.
|
|
> the intended command for the image.
|
|
|
|
|
|
@@ -751,7 +753,7 @@ and
|
|
ENV myDog Rex The Dog
|
|
ENV myDog Rex The Dog
|
|
ENV myCat fluffy
|
|
ENV myCat fluffy
|
|
|
|
|
|
-will yield the same net results in the final container, but the first form
|
|
|
|
|
|
+will yield the same net results in the final image, but the first form
|
|
is preferred because it produces a single cache layer.
|
|
is preferred because it produces a single cache layer.
|
|
|
|
|
|
The environment variables set using `ENV` will persist when a container is run
|
|
The environment variables set using `ENV` will persist when a container is run
|
|
@@ -773,7 +775,7 @@ ADD has two forms:
|
|
whitespace)
|
|
whitespace)
|
|
|
|
|
|
The `ADD` instruction copies new files, directories or remote file URLs from `<src>`
|
|
The `ADD` instruction copies new files, directories or remote file URLs from `<src>`
|
|
-and adds them to the filesystem of the container at the path `<dest>`.
|
|
|
|
|
|
+and adds them to the filesystem of the image at the path `<dest>`.
|
|
|
|
|
|
Multiple `<src>` resource may be specified but if they are files or
|
|
Multiple `<src>` resource may be specified but if they are files or
|
|
directories then they must be relative to the source directory that is
|
|
directories then they must be relative to the source directory that is
|
|
@@ -806,7 +808,7 @@ of whether or not the file has changed and the cache should be updated.
|
|
> can only contain a URL based `ADD` instruction. You can also pass a
|
|
> can only contain a URL based `ADD` instruction. You can also pass a
|
|
> compressed archive through STDIN: (`docker build - < archive.tar.gz`),
|
|
> compressed archive through STDIN: (`docker build - < archive.tar.gz`),
|
|
> the `Dockerfile` at the root of the archive and the rest of the
|
|
> the `Dockerfile` at the root of the archive and the rest of the
|
|
-> archive will get used at the context of the build.
|
|
|
|
|
|
+> archive will be used as the context of the build.
|
|
|
|
|
|
> **Note**:
|
|
> **Note**:
|
|
> If your URL files are protected using authentication, you
|
|
> If your URL files are protected using authentication, you
|
|
@@ -848,7 +850,7 @@ guide](../userguide/eng-image/dockerfile_best-practices.md#build-cache) for more
|
|
- If `<src>` is a *local* tar archive in a recognized compression format
|
|
- If `<src>` is a *local* tar archive in a recognized compression format
|
|
(identity, gzip, bzip2 or xz) then it is unpacked as a directory. Resources
|
|
(identity, gzip, bzip2 or xz) then it is unpacked as a directory. Resources
|
|
from *remote* URLs are **not** decompressed. When a directory is copied or
|
|
from *remote* URLs are **not** decompressed. When a directory is copied or
|
|
- unpacked, it has the same behavior as `tar -x`: the result is the union of:
|
|
|
|
|
|
+ unpacked, it has the same behavior as `tar -x`, the result is the union of:
|
|
|
|
|
|
1. Whatever existed at the destination path and
|
|
1. Whatever existed at the destination path and
|
|
2. The contents of the source tree, with conflicts resolved in favor
|
|
2. The contents of the source tree, with conflicts resolved in favor
|
|
@@ -1677,7 +1679,7 @@ a shell operates. For example, using `SHELL cmd /S /C /V:ON|OFF` on Windows, del
|
|
environment variable expansion semantics could be modified.
|
|
environment variable expansion semantics could be modified.
|
|
|
|
|
|
The `SHELL` instruction can also be used on Linux should an alternate shell be
|
|
The `SHELL` instruction can also be used on Linux should an alternate shell be
|
|
-required such `zsh`, `csh`, `tcsh` and others.
|
|
|
|
|
|
+required such as `zsh`, `csh`, `tcsh` and others.
|
|
|
|
|
|
The `SHELL` feature was added in Docker 1.12.
|
|
The `SHELL` feature was added in Docker 1.12.
|
|
|
|
|