Browse code

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>

Sebastiaan van Stijn authored on 2016/08/15 20:32:03
Showing 8 changed files
... ...
@@ -1252,13 +1252,9 @@ or being killed.
1252 1252
         ignored if `remote` is specified and points to an individual filename.
1253 1253
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1254 1254
         If you omit the `tag` the default `latest` value is assumed.
1255
--   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1256
-        URI points to a single text file, the file's contents are placed into
1257
-        a file called `Dockerfile` and the image is built from that file. If
1258
-        the URI points to a tarball, the file is downloaded by the daemon and
1259
-        the contents therein used as the context for the build. If the URI
1260
-        points to a tarball and the `dockerfile` parameter is also specified,
1261
-        there must be a file with the corresponding path inside the tarball.
1255
+-   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the
1256
+        URI specifies a filename, the file's contents are placed into a file
1257
+        called `Dockerfile`.
1262 1258
 -   **q** – Suppress verbose build output.
1263 1259
 -   **nocache** – Do not use the cache when building the image.
1264 1260
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -1375,13 +1375,17 @@ or being killed.
1375 1375
 
1376 1376
 **Query parameters**:
1377 1377
 
1378
--   **dockerfile** - Path within the build context to the Dockerfile. This is
1379
-        ignored if `remote` is specified and points to an individual filename.
1378
+-   **dockerfile** - Path within the build context to the `Dockerfile`. This is
1379
+        ignored if `remote` is specified and points to an external `Dockerfile`.
1380 1380
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1381 1381
         If you omit the `tag` the default `latest` value is assumed.
1382 1382
 -   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1383 1383
         URI points to a single text file, the file's contents are placed into
1384
-        a file called `Dockerfile` and the image is built from that file.
1384
+        a file called `Dockerfile` and the image is built from that file. If
1385
+        the URI points to a tarball, the file is downloaded by the daemon and
1386
+        the contents therein used as the context for the build. If the URI
1387
+        points to a tarball and the `dockerfile` parameter is also specified,
1388
+        there must be a file with the corresponding path inside the tarball.
1385 1389
 -   **q** – Suppress verbose build output.
1386 1390
 -   **nocache** – Do not use the cache when building the image.
1387 1391
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -1453,14 +1453,18 @@ or being killed.
1453 1453
 
1454 1454
 **Query parameters**:
1455 1455
 
1456
--   **dockerfile** - Path within the build context to the Dockerfile. This is
1457
-        ignored if `remote` is specified and points to an individual filename.
1456
+-   **dockerfile** - Path within the build context to the `Dockerfile`. This is
1457
+        ignored if `remote` is specified and points to an external `Dockerfile`.
1458 1458
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1459 1459
         If you omit the `tag` the default `latest` value is assumed.
1460 1460
         You can provide one or more `t` parameters.
1461 1461
 -   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1462 1462
         URI points to a single text file, the file's contents are placed into
1463
-        a file called `Dockerfile` and the image is built from that file.
1463
+        a file called `Dockerfile` and the image is built from that file. If
1464
+        the URI points to a tarball, the file is downloaded by the daemon and
1465
+        the contents therein used as the context for the build. If the URI
1466
+        points to a tarball and the `dockerfile` parameter is also specified,
1467
+        there must be a file with the corresponding path inside the tarball.
1464 1468
 -   **q** – Suppress verbose build output.
1465 1469
 -   **nocache** – Do not use the cache when building the image.
1466 1470
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -1630,14 +1630,18 @@ or being killed.
1630 1630
 
1631 1631
 **Query parameters**:
1632 1632
 
1633
--   **dockerfile** - Path within the build context to the Dockerfile. This is
1634
-        ignored if `remote` is specified and points to an individual filename.
1633
+-   **dockerfile** - Path within the build context to the `Dockerfile`. This is
1634
+        ignored if `remote` is specified and points to an external `Dockerfile`.
1635 1635
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1636 1636
         If you omit the `tag` the default `latest` value is assumed.
1637 1637
         You can provide one or more `t` parameters.
1638 1638
 -   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1639 1639
         URI points to a single text file, the file's contents are placed into
1640
-        a file called `Dockerfile` and the image is built from that file.
1640
+        a file called `Dockerfile` and the image is built from that file. If
1641
+        the URI points to a tarball, the file is downloaded by the daemon and
1642
+        the contents therein used as the context for the build. If the URI
1643
+        points to a tarball and the `dockerfile` parameter is also specified,
1644
+        there must be a file with the corresponding path inside the tarball.
1641 1645
 -   **q** – Suppress verbose build output.
1642 1646
 -   **nocache** – Do not use the cache when building the image.
1643 1647
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -1663,14 +1663,18 @@ or being killed.
1663 1663
 
1664 1664
 **Query parameters**:
1665 1665
 
1666
--   **dockerfile** - Path within the build context to the Dockerfile. This is
1667
-        ignored if `remote` is specified and points to an individual filename.
1666
+-   **dockerfile** - Path within the build context to the `Dockerfile`. This is
1667
+        ignored if `remote` is specified and points to an external `Dockerfile`.
1668 1668
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1669 1669
         If you omit the `tag` the default `latest` value is assumed.
1670 1670
         You can provide one or more `t` parameters.
1671 1671
 -   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1672 1672
         URI points to a single text file, the file's contents are placed into
1673
-        a file called `Dockerfile` and the image is built from that file.
1673
+        a file called `Dockerfile` and the image is built from that file. If
1674
+        the URI points to a tarball, the file is downloaded by the daemon and
1675
+        the contents therein used as the context for the build. If the URI
1676
+        points to a tarball and the `dockerfile` parameter is also specified,
1677
+        there must be a file with the corresponding path inside the tarball.
1674 1678
 -   **q** – Suppress verbose build output.
1675 1679
 -   **nocache** – Do not use the cache when building the image.
1676 1680
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -1664,14 +1664,18 @@ or being killed.
1664 1664
 
1665 1665
 **Query parameters**:
1666 1666
 
1667
--   **dockerfile** - Path within the build context to the Dockerfile. This is
1668
-        ignored if `remote` is specified and points to an individual filename.
1667
+-   **dockerfile** - Path within the build context to the `Dockerfile`. This is
1668
+        ignored if `remote` is specified and points to an external `Dockerfile`.
1669 1669
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1670 1670
         If you omit the `tag` the default `latest` value is assumed.
1671 1671
         You can provide one or more `t` parameters.
1672 1672
 -   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1673 1673
         URI points to a single text file, the file's contents are placed into
1674
-        a file called `Dockerfile` and the image is built from that file.
1674
+        a file called `Dockerfile` and the image is built from that file. If
1675
+        the URI points to a tarball, the file is downloaded by the daemon and
1676
+        the contents therein used as the context for the build. If the URI
1677
+        points to a tarball and the `dockerfile` parameter is also specified,
1678
+        there must be a file with the corresponding path inside the tarball.
1675 1679
 -   **q** – Suppress verbose build output.
1676 1680
 -   **nocache** – Do not use the cache when building the image.
1677 1681
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -1669,14 +1669,18 @@ or being killed.
1669 1669
 
1670 1670
 **Query parameters**:
1671 1671
 
1672
--   **dockerfile** - Path within the build context to the Dockerfile. This is
1673
-        ignored if `remote` is specified and points to an individual filename.
1672
+-   **dockerfile** - Path within the build context to the `Dockerfile`. This is
1673
+        ignored if `remote` is specified and points to an external `Dockerfile`.
1674 1674
 -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
1675 1675
         If you omit the `tag` the default `latest` value is assumed.
1676 1676
         You can provide one or more `t` parameters.
1677 1677
 -   **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1678 1678
         URI points to a single text file, the file's contents are placed into
1679
-        a file called `Dockerfile` and the image is built from that file.
1679
+        a file called `Dockerfile` and the image is built from that file. If
1680
+        the URI points to a tarball, the file is downloaded by the daemon and
1681
+        the contents therein used as the context for the build. If the URI
1682
+        points to a tarball and the `dockerfile` parameter is also specified,
1683
+        there must be a file with the corresponding path inside the tarball.
1680 1684
 -   **q** – Suppress verbose build output.
1681 1685
 -   **nocache** – Do not use the cache when building the image.
1682 1686
 -   **pull** - Attempt to pull the image even if an older image exists locally.
... ...
@@ -49,13 +49,18 @@ to any of the files in the context. For example, your build can use an
49 49
 [*ADD*](../builder.md#add) instruction to reference a file in the
50 50
 context.
51 51
 
52
-The `URL` parameter can specify the location of a Git repository; the repository
53
-acts as the build context. The system recursively clones the repository and its
54
-submodules using a `git clone --depth 1 --recursive` command. This command runs
55
-in a temporary directory on your local host. After the command succeeds, the
56
-directory is sent to the Docker daemon as the context. Local clones give you the
57
-ability to access private repositories using local user credentials, VPNs, and
58
-so forth.
52
+The `URL` parameter can refer to three kinds of resources: Git repositories,
53
+pre-packaged tarball contexts and plain text files.
54
+
55
+### Git repositories
56
+
57
+When the `URL` parameter points to the location of a Git repository, the
58
+repository acts as the build context. The system recursively clones the
59
+repository and its submodules using a `git clone --depth 1 --recursive`
60
+command. This command runs in a temporary directory on your local host. After
61
+the command succeeds, the directory is sent to the Docker daemon as the
62
+context. Local clones give you the ability to access private repositories using
63
+local user credentials, VPN's, and so forth.
59 64
 
60 65
 Git URLs accept context configuration in their fragment section, separated by a
61 66
 colon `:`.  The first part represents the reference that Git will check out,
... ...
@@ -84,10 +89,30 @@ Build Syntax Suffix             | Commit Used           | Build Context Used
84 84
 `myrepo.git#mybranch:myfolder`  | `refs/heads/mybranch` | `/myfolder`
85 85
 `myrepo.git#abcdef:myfolder`    | `sha1 = abcdef`       | `/myfolder`
86 86
 
87
+
88
+### Tarball contexts
89
+
90
+If you pass an URL to a remote tarball, the URL itself is sent to the daemon:
91
+
87 92
 Instead of specifying a context, you can pass a single Dockerfile in the `URL`
88 93
 or pipe the file in via `STDIN`. To pipe a Dockerfile from `STDIN`:
89 94
 
90 95
 ```bash
96
+$ docker build http://server/context.tar.gz
97
+
98
+The download operation will be performed on the host the Docker daemon is
99
+running on, which is not necessarily the same host from which the build command
100
+is being issued. The Docker daemon will fetch `context.tar.gz` and use it as the
101
+build context. Tarball contexts must be tar archives conforming to the standard
102
+`tar` UNIX format and can be compressed with any one of the 'xz', 'bzip2',
103
+'gzip' or 'identity' (no compression) formats.
104
+
105
+### Text files
106
+
107
+Instead of specifying a context, you can pass a single `Dockerfile` in the
108
+`URL` or pipe the file in via `STDIN`. To pipe a `Dockerfile` from `STDIN`:
109
+
110
+```bash
91 111
 $ docker build - < Dockerfile
92 112
 ```
93 113
 
... ...
@@ -97,16 +122,16 @@ With Powershell on Windows, you can run:
97 97
 Get-Content Dockerfile | docker build -
98 98
 ```
99 99
 
100
-If you use STDIN or specify a `URL`, the system places the contents into a file
101
-called `Dockerfile`, and any `-f`, `--file` option is ignored. In this
102
-scenario, there is no context.
100
+If you use `STDIN` or specify a `URL` pointing to a plain text file, the system
101
+places the contents into a file called `Dockerfile`, and any `-f`, `--file`
102
+option is ignored. In this scenario, there is no context.
103 103
 
104 104
 By default the `docker build` command will look for a `Dockerfile` at the root
105 105
 of the build context. The `-f`, `--file`, option lets you specify the path to
106 106
 an alternative file to use instead. This is useful in cases where the same set
107 107
 of files are used for multiple builds. The path must be to a file within the
108
-build context. If a relative path is specified then it must to be relative to
109
-the current directory.
108
+build context. If a relative path is specified then it is interpreted as
109
+relative to the root of the context.
110 110
 
111 111
 In most cases, it's best to put each Dockerfile in an empty directory. Then,
112 112
 add to that directory only the files needed for building the Dockerfile. To
... ...
@@ -199,9 +224,32 @@ $ docker build github.com/creack/docker-firefox
199 199
 ```
200 200
 
201 201
 This will clone the GitHub repository and use the cloned repository as context.
202
-The Dockerfile at the root of the repository is used as Dockerfile. Note that
203
-you can specify an arbitrary Git repository by using the `git://` or `git@`
204
-scheme.
202
+The Dockerfile at the root of the repository is used as Dockerfile. You can
203
+specify an arbitrary Git repository by using the `git://` or `git@` scheme.
204
+
205
+```bash
206
+$ docker build -f ctx/Dockerfile http://server/ctx.tar.gz
207
+
208
+Downloading context: http://server/ctx.tar.gz [===================>]    240 B/240 B
209
+Step 0 : FROM busybox
210
+ ---> 8c2e06607696
211
+Step 1 : ADD ctx/container.cfg /
212
+ ---> e7829950cee3
213
+Removing intermediate container b35224abf821
214
+Step 2 : CMD /bin/ls
215
+ ---> Running in fbc63d321d73
216
+ ---> 3286931702ad
217
+Removing intermediate container fbc63d321d73
218
+Successfully built 377c409b35e4
219
+```
220
+
221
+This sends the URL `http://server/ctx.tar.gz` to the Docker daemon, which
222
+downloads and extracts the referenced tarball. The `-f ctx/Dockerfile`
223
+parameter specifies a path inside `ctx.tar.gz` to the `Dockerfile` that is used
224
+to build the image. Any `ADD` commands in that `Dockerfile` that refer to local
225
+paths must be relative to the root of the contents inside `ctx.tar.gz`. In the
226
+example above, the tarball contains a directory `ctx/`, so the `ADD
227
+ctx/container.cfg /` operation works as expected.
205 228
 
206 229
 ### Build with -
207 230