|
1 | | ---- |
2 | | -title: "build" |
3 | | -description: "The build command description and usage" |
4 | | -keywords: "build, docker, image" |
5 | | ---- |
6 | | - |
7 | 1 | # build |
8 | 2 |
|
9 | | -```markdown |
10 | | -Usage: docker build [OPTIONS] PATH | URL | - |
11 | | - |
| 3 | +<!---MARKER_GEN_START--> |
12 | 4 | Build an image from a Dockerfile |
13 | 5 |
|
14 | | -Aliases: |
15 | | - docker image build, docker build, docker buildx build, docker builder build |
16 | | - |
17 | | -Options: |
18 | | - --add-host value Add a custom host-to-IP mapping (host:ip) (default []) |
19 | | - --build-arg value Set build-time variables (default []) |
20 | | - --cache-from value Images to consider as cache sources (default []) |
21 | | - --cgroup-parent string Optional parent cgroup for the container |
22 | | - --compress Compress the build context using gzip |
23 | | - --cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period |
24 | | - --cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota |
25 | | - -c, --cpu-shares int CPU shares (relative weight) |
26 | | - --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) |
27 | | - --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) |
28 | | - --disable-content-trust Skip image verification (default true) |
29 | | - -f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile') |
30 | | - --force-rm Always remove intermediate containers |
31 | | - --help Print usage |
32 | | - --iidfile string Write the image ID to the file |
33 | | - --isolation string Container isolation technology |
34 | | - --label value Set metadata for an image (default []) |
35 | | - -m, --memory string Memory limit |
36 | | - --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
37 | | - --network string Set the networking mode for the RUN instructions during build |
38 | | - 'bridge': use default Docker bridge |
39 | | - 'none': no networking |
40 | | - 'container:<name|id>': reuse another container's network stack |
41 | | - 'host': use the Docker host network stack |
42 | | - '<network-name>|<network-id>': connect to a user-defined network |
43 | | - --no-cache Do not use cache when building the image |
44 | | - -o, --output Output destination (format: type=local,dest=path) |
45 | | - --pull Always attempt to pull a newer version of the image |
46 | | - --progress Set type of progress output (only if BuildKit enabled) (auto, plain, tty). |
47 | | - Use plain to show container output |
48 | | - -q, --quiet Suppress the build output and print image ID on success |
49 | | - --rm Remove intermediate containers after a successful build (default true) |
50 | | - --secret Secret file to expose to the build (only if BuildKit enabled): id=mysecret,src=/local/secret" |
51 | | - --security-opt value Security Options (default []) |
52 | | - --shm-size bytes Size of /dev/shm |
53 | | - The format is `<number><unit>`. `number` must be greater than `0`. |
54 | | - Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), |
55 | | - or `g` (gigabytes). If you omit the unit, the system uses bytes. |
56 | | - --squash Squash newly built layers into a single new layer (**Experimental Only**) |
57 | | - --ssh SSH agent socket or keys to expose to the build (only if BuildKit enabled) (format: default|<id>[=<socket>|<key>[,<key>]]) |
58 | | - -t, --tag value Name and optionally a tag in the 'name:tag' format (default []) |
59 | | - --target string Set the target build stage to build. |
60 | | - --ulimit value Ulimit options (default []) |
61 | | -``` |
| 6 | +### Aliases |
| 7 | + |
| 8 | +`docker image build`, `docker build`, `docker buildx build`, `docker builder build` |
| 9 | + |
| 10 | +### Options |
| 11 | + |
| 12 | +| Name | Type | Default | Description | |
| 13 | +|:--------------------------|:--------------|:----------|:------------------------------------------------------------------| |
| 14 | +| `--add-host` | `list` | | Add a custom host-to-IP mapping (`host:ip`) | |
| 15 | +| `--build-arg` | `list` | | Set build-time variables | |
| 16 | +| `--cache-from` | `stringSlice` | | Images to consider as cache sources | |
| 17 | +| `--cgroup-parent` | `string` | | Optional parent cgroup for the container | |
| 18 | +| `--compress` | | | Compress the build context using gzip | |
| 19 | +| `--cpu-period` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) period | |
| 20 | +| `--cpu-quota` | `int64` | `0` | Limit the CPU CFS (Completely Fair Scheduler) quota | |
| 21 | +| `-c`, `--cpu-shares` | `int64` | `0` | CPU shares (relative weight) | |
| 22 | +| `--cpuset-cpus` | `string` | | CPUs in which to allow execution (0-3, 0,1) | |
| 23 | +| `--cpuset-mems` | `string` | | MEMs in which to allow execution (0-3, 0,1) | |
| 24 | +| `--disable-content-trust` | | | Skip image verification | |
| 25 | +| `-f`, `--file` | `string` | | Name of the Dockerfile (Default is `PATH/Dockerfile`) | |
| 26 | +| `--force-rm` | | | Always remove intermediate containers | |
| 27 | +| `--iidfile` | `string` | | Write the image ID to the file | |
| 28 | +| `--isolation` | `string` | | Container isolation technology | |
| 29 | +| `--label` | `list` | | Set metadata for an image | |
| 30 | +| `-m`, `--memory` | `bytes` | `0` | Memory limit | |
| 31 | +| `--memory-swap` | `bytes` | `0` | Swap limit equal to memory plus swap: -1 to enable unlimited swap | |
| 32 | +| `--network` | `string` | `default` | Set the networking mode for the RUN instructions during build | |
| 33 | +| `--no-cache` | | | Do not use cache when building the image | |
| 34 | +| `--platform` | `string` | | Set platform if server is multi-platform capable | |
| 35 | +| `--pull` | | | Always attempt to pull a newer version of the image | |
| 36 | +| `-q`, `--quiet` | | | Suppress the build output and print image ID on success | |
| 37 | +| `--rm` | | | Remove intermediate containers after a successful build | |
| 38 | +| `--security-opt` | `stringSlice` | | Security options | |
| 39 | +| `--shm-size` | `bytes` | `0` | Size of `/dev/shm` | |
| 40 | +| `--squash` | | | Squash newly built layers into a single new layer | |
| 41 | +| `-t`, `--tag` | `list` | | Name and optionally a tag in the `name:tag` format | |
| 42 | +| `--target` | `string` | | Set the target build stage to build. | |
| 43 | +| `--ulimit` | `ulimit` | | Ulimit options | |
| 44 | + |
| 45 | + |
| 46 | +<!---MARKER_GEN_END--> |
62 | 47 |
|
63 | 48 | ## Description |
64 | 49 |
|
|
0 commit comments