Signed-off-by: Madhav Puri <madhav.puri@gmail.com>
| ... | ... |
@@ -1367,11 +1367,11 @@ Query Parameters: |
| 1367 | 1367 |
- **memswap** - Total memory (memory + swap), `-1` to disable swap. |
| 1368 | 1368 |
- **cpushares** - CPU shares (relative weight). |
| 1369 | 1369 |
- **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). |
| 1370 |
-- **buildargs** – JSON map of string pairs for build-time variables. Users can |
|
| 1371 |
- set these values at build-time and they are used as environment context |
|
| 1372 |
- for the command(s) run as part of the Dockerfile's `RUN` instruction or |
|
| 1373 |
- for variable expansion in other Dockerfile instructions. Read more about |
|
| 1374 |
- the `ARG` instruction [here](/reference/builder/#arg) |
|
| 1370 |
+- **buildargs** – JSON map of string pairs for build-time variables. Users pass |
|
| 1371 |
+ these values at build-time. Docker uses the `buildargs` as the environment |
|
| 1372 |
+ context for command(s) run via the Dockerfile's `RUN` instruction or for |
|
| 1373 |
+ variable expansion in other Dockerfile instructions. This is not meant for |
|
| 1374 |
+ passing secret values. [Read more about the buildargs instruction](/reference/builder/#arg) |
|
| 1375 | 1375 |
|
| 1376 | 1376 |
Request Headers: |
| 1377 | 1377 |
|
| ... | ... |
@@ -1058,19 +1058,20 @@ useful interactions between `ARG` and `ENV` instructions: |
| 1058 | 1058 |
4 RUN echo $CONT_IMG_VER |
| 1059 | 1059 |
``` |
| 1060 | 1060 |
|
| 1061 |
-The command line passes the `--build-arg` and sets the `v2.0.1` value. And the `ARG |
|
| 1062 |
-CONT_IMG_VER` is defined on line 2 of the Dockerfile. On line 3, the `ENV` |
|
| 1063 |
-instruction of the same name resolves to `v2.0.1` as the build-time variable |
|
| 1064 |
-was passed from the command line and expanded here. |
|
| 1061 |
+Unlike an `ARG` instruction, `ENV` values are always persisted in the built |
|
| 1062 |
+image. Consider a docker build without the --build-arg flag: |
|
| 1065 | 1063 |
|
| 1066 |
-The variable expansion technique in this example allows you to pass arguments |
|
| 1067 |
-from the command line and persist them in the final image by leveraging the `ENV` |
|
| 1068 |
-instruction. Variable expansion is only supported for the `Dockerfile` instructions |
|
| 1069 |
-described [here](#environment-replacement). |
|
| 1064 |
+``` |
|
| 1065 |
+$ docker build Dockerfile |
|
| 1066 |
+``` |
|
| 1070 | 1067 |
|
| 1071 |
-Unlike an `ARG` instruction, `ENV` values are always persisted in the built image. If |
|
| 1072 |
-`docker build` were run without setting the `--build-arg` flag, then |
|
| 1073 |
-`CONT_IMG_VER` is still persisted in the image but its value would be `v1.0.0`. |
|
| 1068 |
+Using this Dockerfile example, `CONT_IMG_VER` is still persisted in the image but |
|
| 1069 |
+its value would be `v1.0.0` as it is the default set in line 3 by the `ENV` instruction. |
|
| 1070 |
+ |
|
| 1071 |
+The variable expansion technique in this example allows you to pass arguments |
|
| 1072 |
+from the command line and persist them in the final image by leveraging the |
|
| 1073 |
+`ENV` instruction. Variable expansion is only supported for [a limited set of |
|
| 1074 |
+Dockerfile instructions.](#environment-replacement) |
|
| 1074 | 1075 |
|
| 1075 | 1076 |
Docker has a set of predefined `ARG` variables that you can use without a |
| 1076 | 1077 |
corresponding `ARG` instruction in the Dockerfile. |
| ... | ... |
@@ -408,19 +408,20 @@ A Dockerfile is similar to a Makefile. |
| 408 | 408 |
4 RUN echo $CONT_IMG_VER |
| 409 | 409 |
``` |
| 410 | 410 |
|
| 411 |
- The command line passes the `--build-arg` and sets the `v2.0.1` value. And the `ARG |
|
| 412 |
- CONT_IMG_VER` is defined on line 2 of the Dockerfile. On line 3, the `ENV` |
|
| 413 |
- instruction of the same name resolves to `v2.0.1` as the build-time variable |
|
| 414 |
- was passed from the command line and expanded here. |
|
| 411 |
+ Unlike an `ARG` instruction, `ENV` values are always persisted in the built |
|
| 412 |
+ image. Consider a docker build without the --build-arg flag: |
|
| 415 | 413 |
|
| 416 |
- The variable expansion technique in this example allows you to pass arguments |
|
| 417 |
- from the command line and persist them in the final image by leveraging the `ENV` |
|
| 418 |
- instruction. Variable expansion is only supported for the `Dockerfile` instructions |
|
| 419 |
- described [here](#environment-replacement). |
|
| 414 |
+ ``` |
|
| 415 |
+ $ docker build Dockerfile |
|
| 416 |
+ ``` |
|
| 420 | 417 |
|
| 421 |
- Unlike an `ARG` instruction, `ENV` values are always persisted in the built image. If |
|
| 422 |
- `docker build` were run without setting the `--build-arg` flag, then |
|
| 423 |
- `CONT_IMG_VER` is still persisted in the image but its value would be `v1.0.0`. |
|
| 418 |
+ Using this Dockerfile example, `CONT_IMG_VER` is still persisted in the image but |
|
| 419 |
+ its value would be `v1.0.0` as it is the default set in line 3 by the `ENV` instruction. |
|
| 420 |
+ |
|
| 421 |
+ The variable expansion technique in this example allows you to pass arguments |
|
| 422 |
+ from the command line and persist them in the final image by leveraging the |
|
| 423 |
+ `ENV` instruction. Variable expansion is only supported for [a limited set of |
|
| 424 |
+ Dockerfile instructions.](#environment-replacement) |
|
| 424 | 425 |
|
| 425 | 426 |
Docker has a set of predefined `ARG` variables that you can use without a |
| 426 | 427 |
corresponding `ARG` instruction in the Dockerfile. |
| ... | ... |
@@ -53,22 +53,15 @@ cloned locally and then sent as the context. |
| 53 | 53 |
The default is *Dockerfile*. |
| 54 | 54 |
|
| 55 | 55 |
**--build-arg**=*variable* |
| 56 |
- Set value for build-time variable. This option allows you to specify |
|
| 57 |
-values of the variables that are available for expansion/substitution in the |
|
| 58 |
-Dockerfile instructions like ADD, COPY etc, without an explicit prior definition by |
|
| 59 |
-the ENV instruction. The build-time variables are also passed as environment |
|
| 60 |
-context for the command(s) that will be executed as part of RUN instruction |
|
| 61 |
-of Dockerfile, if there is no explicit prior definition by the ENV instruction. |
|
| 62 |
-Normally, these variables are not persisted in the resulting Docker image. This gives |
|
| 63 |
-the flexibility to build an image by passing host specific environment variables (like |
|
| 64 |
-http_proxy) that will be used on the RUN commands without affecting portability |
|
| 65 |
-of the generated image. |
|
| 66 |
-However, as with any variable, they can be persisted in the final image if they are used in an |
|
| 67 |
-ENV instruction (e.g. ENV myName=$myName will save myName in the image). |
|
| 68 |
- |
|
| 69 |
-Only the build-time variables that are defined using the ARG instruction of Dockerfile |
|
| 70 |
-are allowed to be expanded or passed as environment to the RUN command. Read more about |
|
| 71 |
-ARG instruction in Dockerfile reference. |
|
| 56 |
+ name and value of a **buildarg**. |
|
| 57 |
+ |
|
| 58 |
+ For example, if you want to pass a value for `http_proxy`, use |
|
| 59 |
+ `--bulid-arg=http_proxy="http://some.proxy.url"` |
|
| 60 |
+ |
|
| 61 |
+ Users pass these values at build-time. Docker uses the `buildargs` as the |
|
| 62 |
+ environment context for command(s) run via the Dockerfile's `RUN` instruction |
|
| 63 |
+ or for variable expansion in other Dockerfile instructions. This is not meant |
|
| 64 |
+ for passing secret values. [Read more about the buildargs instruction](/reference/builder/#arg) |
|
| 72 | 65 |
|
| 73 | 66 |
**--force-rm**=*true*|*false* |
| 74 | 67 |
Always remove intermediate containers, even after unsuccessful builds. The default is *false*. |