docs: add docs for build —target
| ... | ... |
@@ -57,6 +57,7 @@ Options: |
| 57 | 57 |
or `g` (gigabytes). If you omit the unit, the system uses bytes. |
| 58 | 58 |
--squash Squash newly built layers into a single new layer (**Experimental Only**) |
| 59 | 59 |
-t, --tag value Name and optionally a tag in the 'name:tag' format (default []) |
| 60 |
+ --target string Set the target build stage to build. |
|
| 60 | 61 |
--ulimit value Ulimit options (default []) |
| 61 | 62 |
``` |
| 62 | 63 |
|
| ... | ... |
@@ -454,6 +455,24 @@ more `--add-host` flags. This example adds a static address for a host named |
| 454 | 454 |
|
| 455 | 455 |
$ docker build --add-host=docker:10.180.0.1 . |
| 456 | 456 |
|
| 457 |
+### Specifying target build stage (--target) |
|
| 458 |
+ |
|
| 459 |
+When building a Dockerfile with multiple build stages, `--target` can be used to |
|
| 460 |
+specify an intermediate build stage by name as a final stage for the resulting |
|
| 461 |
+image. Commands after the target stage will be skipped. |
|
| 462 |
+ |
|
| 463 |
+```Dockerfile |
|
| 464 |
+FROM debian AS build-env |
|
| 465 |
+... |
|
| 466 |
+ |
|
| 467 |
+FROM alpine AS production-env |
|
| 468 |
+... |
|
| 469 |
+``` |
|
| 470 |
+ |
|
| 471 |
+```bash |
|
| 472 |
+$ docker build -t mybuildimage --target build-env . |
|
| 473 |
+``` |
|
| 474 |
+ |
|
| 457 | 475 |
### Squash an image's layers (--squash) **Experimental Only** |
| 458 | 476 |
|
| 459 | 477 |
#### Overview |
| ... | ... |
@@ -8,6 +8,7 @@ docker-build - Build an image from a Dockerfile |
| 8 | 8 |
**docker build** |
| 9 | 9 |
[**--add-host**[=*[]*]] |
| 10 | 10 |
[**--build-arg**[=*[]*]] |
| 11 |
+[**--cache-from**[=*[]*]] |
|
| 11 | 12 |
[**--cpu-shares**[=*0*]] |
| 12 | 13 |
[**--cgroup-parent**[=*CGROUP-PARENT*]] |
| 13 | 14 |
[**--help**] |
| ... | ... |
@@ -31,6 +32,7 @@ docker-build - Build an image from a Dockerfile |
| 31 | 31 |
[**--cpu-quota**[=*0*]] |
| 32 | 32 |
[**--cpuset-cpus**[=*CPUSET-CPUS*]] |
| 33 | 33 |
[**--cpuset-mems**[=*CPUSET-MEMS*]] |
| 34 |
+[**--target**[=*[]*]] |
|
| 34 | 35 |
[**--ulimit**[=*[]*]] |
| 35 | 36 |
PATH | URL | - |
| 36 | 37 |
|
| ... | ... |
@@ -93,6 +95,9 @@ option can be set multiple times. |
| 93 | 93 |
or for variable expansion in other Dockerfile instructions. This is not meant |
| 94 | 94 |
for passing secret values. [Read more about the buildargs instruction](https://docs.docker.com/engine/reference/builder/#arg) |
| 95 | 95 |
|
| 96 |
+**--cache-from**="" |
|
| 97 |
+ Set image that will be used as a build cache source. |
|
| 98 |
+ |
|
| 96 | 99 |
**--force-rm**=*true*|*false* |
| 97 | 100 |
Always remove intermediate containers, even after unsuccessful builds. The default is *false*. |
| 98 | 101 |
|
| ... | ... |
@@ -233,6 +238,9 @@ two memory nodes. |
| 233 | 233 |
If the path is not absolute, the path is considered relative to the `cgroups` path of the init process. |
| 234 | 234 |
Cgroups are created if they do not already exist. |
| 235 | 235 |
|
| 236 |
+**--target**="" |
|
| 237 |
+ Set the target build stage name. |
|
| 238 |
+ |
|
| 236 | 239 |
**--ulimit**=[] |
| 237 | 240 |
Ulimit options |
| 238 | 241 |
|