mirror of https://github.com/docker/cli.git
Add missing docs about binary remote contexts
This feature was added in docker 1.8, through 7491f9a9c11ad3fd3b587fa6f7e53b297b3b88c7. However, the API docs ended up in the wrong API version (1.19 instead of 1.20), so were never included in future API docs. Also, the CLI docs got lost during splitting up the cli.md docs into separate files; 561bfb268de3c674b04d48895b7e46ae890ef795 This moves the API docs to the correct versions, and restores the CLI documentation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1ccb0210f5
commit
f68f53f3ec
|
@ -49,13 +49,18 @@ to any of the files in the context. For example, your build can use an
|
||||||
[*ADD*](../builder.md#add) instruction to reference a file in the
|
[*ADD*](../builder.md#add) instruction to reference a file in the
|
||||||
context.
|
context.
|
||||||
|
|
||||||
The `URL` parameter can specify the location of a Git repository; the repository
|
The `URL` parameter can refer to three kinds of resources: Git repositories,
|
||||||
acts as the build context. The system recursively clones the repository and its
|
pre-packaged tarball contexts and plain text files.
|
||||||
submodules using a `git clone --depth 1 --recursive` command. This command runs
|
|
||||||
in a temporary directory on your local host. After the command succeeds, the
|
### Git repositories
|
||||||
directory is sent to the Docker daemon as the context. Local clones give you the
|
|
||||||
ability to access private repositories using local user credentials, VPNs, and
|
When the `URL` parameter points to the location of a Git repository, the
|
||||||
so forth.
|
repository acts as the build context. The system recursively clones the
|
||||||
|
repository and its submodules using a `git clone --depth 1 --recursive`
|
||||||
|
command. This command runs in a temporary directory on your local host. After
|
||||||
|
the command succeeds, the directory is sent to the Docker daemon as the
|
||||||
|
context. Local clones give you the ability to access private repositories using
|
||||||
|
local user credentials, VPN's, and so forth.
|
||||||
|
|
||||||
Git URLs accept context configuration in their fragment section, separated by a
|
Git URLs accept context configuration in their fragment section, separated by a
|
||||||
colon `:`. The first part represents the reference that Git will check out,
|
colon `:`. The first part represents the reference that Git will check out,
|
||||||
|
@ -84,9 +89,29 @@ Build Syntax Suffix | Commit Used | Build Context Used
|
||||||
`myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder`
|
`myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder`
|
||||||
`myrepo.git#abcdef:myfolder` | `sha1 = abcdef` | `/myfolder`
|
`myrepo.git#abcdef:myfolder` | `sha1 = abcdef` | `/myfolder`
|
||||||
|
|
||||||
|
|
||||||
|
### Tarball contexts
|
||||||
|
|
||||||
|
If you pass an URL to a remote tarball, the URL itself is sent to the daemon:
|
||||||
|
|
||||||
Instead of specifying a context, you can pass a single Dockerfile in the `URL`
|
Instead of specifying a context, you can pass a single Dockerfile in the `URL`
|
||||||
or pipe the file in via `STDIN`. To pipe a Dockerfile from `STDIN`:
|
or pipe the file in via `STDIN`. To pipe a Dockerfile from `STDIN`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker build http://server/context.tar.gz
|
||||||
|
|
||||||
|
The download operation will be performed on the host the Docker daemon is
|
||||||
|
running on, which is not necessarily the same host from which the build command
|
||||||
|
is being issued. The Docker daemon will fetch `context.tar.gz` and use it as the
|
||||||
|
build context. Tarball contexts must be tar archives conforming to the standard
|
||||||
|
`tar` UNIX format and can be compressed with any one of the 'xz', 'bzip2',
|
||||||
|
'gzip' or 'identity' (no compression) formats.
|
||||||
|
|
||||||
|
### Text files
|
||||||
|
|
||||||
|
Instead of specifying a context, you can pass a single `Dockerfile` in the
|
||||||
|
`URL` or pipe the file in via `STDIN`. To pipe a `Dockerfile` from `STDIN`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker build - < Dockerfile
|
$ docker build - < Dockerfile
|
||||||
```
|
```
|
||||||
|
@ -97,16 +122,16 @@ With Powershell on Windows, you can run:
|
||||||
Get-Content Dockerfile | docker build -
|
Get-Content Dockerfile | docker build -
|
||||||
```
|
```
|
||||||
|
|
||||||
If you use STDIN or specify a `URL`, the system places the contents into a file
|
If you use `STDIN` or specify a `URL` pointing to a plain text file, the system
|
||||||
called `Dockerfile`, and any `-f`, `--file` option is ignored. In this
|
places the contents into a file called `Dockerfile`, and any `-f`, `--file`
|
||||||
scenario, there is no context.
|
option is ignored. In this scenario, there is no context.
|
||||||
|
|
||||||
By default the `docker build` command will look for a `Dockerfile` at the root
|
By default the `docker build` command will look for a `Dockerfile` at the root
|
||||||
of the build context. The `-f`, `--file`, option lets you specify the path to
|
of the build context. The `-f`, `--file`, option lets you specify the path to
|
||||||
an alternative file to use instead. This is useful in cases where the same set
|
an alternative file to use instead. This is useful in cases where the same set
|
||||||
of files are used for multiple builds. The path must be to a file within the
|
of files are used for multiple builds. The path must be to a file within the
|
||||||
build context. If a relative path is specified then it must to be relative to
|
build context. If a relative path is specified then it is interpreted as
|
||||||
the current directory.
|
relative to the root of the context.
|
||||||
|
|
||||||
In most cases, it's best to put each Dockerfile in an empty directory. Then,
|
In most cases, it's best to put each Dockerfile in an empty directory. Then,
|
||||||
add to that directory only the files needed for building the Dockerfile. To
|
add to that directory only the files needed for building the Dockerfile. To
|
||||||
|
@ -199,9 +224,32 @@ $ docker build github.com/creack/docker-firefox
|
||||||
```
|
```
|
||||||
|
|
||||||
This will clone the GitHub repository and use the cloned repository as context.
|
This will clone the GitHub repository and use the cloned repository as context.
|
||||||
The Dockerfile at the root of the repository is used as Dockerfile. Note that
|
The Dockerfile at the root of the repository is used as Dockerfile. You can
|
||||||
you can specify an arbitrary Git repository by using the `git://` or `git@`
|
specify an arbitrary Git repository by using the `git://` or `git@` scheme.
|
||||||
scheme.
|
|
||||||
|
```bash
|
||||||
|
$ docker build -f ctx/Dockerfile http://server/ctx.tar.gz
|
||||||
|
|
||||||
|
Downloading context: http://server/ctx.tar.gz [===================>] 240 B/240 B
|
||||||
|
Step 0 : FROM busybox
|
||||||
|
---> 8c2e06607696
|
||||||
|
Step 1 : ADD ctx/container.cfg /
|
||||||
|
---> e7829950cee3
|
||||||
|
Removing intermediate container b35224abf821
|
||||||
|
Step 2 : CMD /bin/ls
|
||||||
|
---> Running in fbc63d321d73
|
||||||
|
---> 3286931702ad
|
||||||
|
Removing intermediate container fbc63d321d73
|
||||||
|
Successfully built 377c409b35e4
|
||||||
|
```
|
||||||
|
|
||||||
|
This sends the URL `http://server/ctx.tar.gz` to the Docker daemon, which
|
||||||
|
downloads and extracts the referenced tarball. The `-f ctx/Dockerfile`
|
||||||
|
parameter specifies a path inside `ctx.tar.gz` to the `Dockerfile` that is used
|
||||||
|
to build the image. Any `ADD` commands in that `Dockerfile` that refer to local
|
||||||
|
paths must be relative to the root of the contents inside `ctx.tar.gz`. In the
|
||||||
|
example above, the tarball contains a directory `ctx/`, so the `ADD
|
||||||
|
ctx/container.cfg /` operation works as expected.
|
||||||
|
|
||||||
### Build with -
|
### Build with -
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue