From 3377664e947979d2609135761a3c559fe47ef758 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 12 May 2017 17:12:10 -0700 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20add=20docs=20for=20build=20?= =?UTF-8?q?=E2=80=94target?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tonis Tiigi --- docs/reference/commandline/build.md | 19 +++++++++++++++++++ man/docker-build.1.md | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/docs/reference/commandline/build.md b/docs/reference/commandline/build.md index d228853472..a26ffef9f0 100644 --- a/docs/reference/commandline/build.md +++ b/docs/reference/commandline/build.md @@ -57,6 +57,7 @@ Options: or `g` (gigabytes). If you omit the unit, the system uses bytes. --squash Squash newly built layers into a single new layer (**Experimental Only**) -t, --tag value Name and optionally a tag in the 'name:tag' format (default []) + --target string Set the target build stage to build. --ulimit value Ulimit options (default []) ``` @@ -454,6 +455,24 @@ more `--add-host` flags. This example adds a static address for a host named $ docker build --add-host=docker:10.180.0.1 . +### Specifying target build stage (--target) + +When building a Dockerfile with multiple build stages, `--target` can be used to +specify an intermediate build stage by name as a final stage for the resulting +image. Commands after the target stage will be skipped. + +```Dockerfile +FROM debian AS build-env +... + +FROM alpine AS production-env +... +``` + +```bash +$ docker build -t mybuildimage --target build-env . +``` + ### Squash an image's layers (--squash) **Experimental Only** #### Overview diff --git a/man/docker-build.1.md b/man/docker-build.1.md index 59eba003a0..1fe51811a3 100644 --- a/man/docker-build.1.md +++ b/man/docker-build.1.md @@ -31,6 +31,7 @@ docker-build - Build an image from a Dockerfile [**--cpu-quota**[=*0*]] [**--cpuset-cpus**[=*CPUSET-CPUS*]] [**--cpuset-mems**[=*CPUSET-MEMS*]] +[**--target**[=*[]*]] [**--ulimit**[=*[]*]] PATH | URL | - @@ -233,6 +234,9 @@ two memory nodes. If the path is not absolute, the path is considered relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist. +**--target**="" + Set the target build stage name. + **--ulimit**=[] Ulimit options From 33054be31bd78422b09a3789c99d7aa5d488e61b Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 15 May 2017 09:58:49 -0700 Subject: [PATCH 2/2] docs: add missing cache-from man docs Signed-off-by: Tonis Tiigi --- man/docker-build.1.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/man/docker-build.1.md b/man/docker-build.1.md index 1fe51811a3..3ac9f81f0f 100644 --- a/man/docker-build.1.md +++ b/man/docker-build.1.md @@ -8,6 +8,7 @@ docker-build - Build an image from a Dockerfile **docker build** [**--add-host**[=*[]*]] [**--build-arg**[=*[]*]] +[**--cache-from**[=*[]*]] [**--cpu-shares**[=*0*]] [**--cgroup-parent**[=*CGROUP-PARENT*]] [**--help**] @@ -94,6 +95,9 @@ option can be set multiple times. or for variable expansion in other Dockerfile instructions. This is not meant for passing secret values. [Read more about the buildargs instruction](https://docs.docker.com/engine/reference/builder/#arg) +**--cache-from**="" + Set image that will be used as a build cache source. + **--force-rm**=*true*|*false* Always remove intermediate containers, even after unsuccessful builds. The default is *false*.