11# buildx build
22
3- ```
3+ ``` text
44docker buildx build [OPTIONS] PATH | URL | -
55```
66
@@ -64,14 +64,14 @@ The `buildx build` command starts a build using BuildKit. This command is simila
6464to the UI of ` docker build ` command and takes the same flags and arguments.
6565
6666For documentation on most of these flags, refer to the [ ` docker build `
67- documentation] ( https://docs.docker.com/engine/reference/commandline/build/ ) . In
68- here we'll document a subset of the new flags.
67+ documentation] ( https://docs.docker.com/engine/reference/commandline/build/ ) .
68+ This page describes a subset of the new flags.
6969
7070## Examples
7171
7272### <a name =" attest " ></a > Create attestations (--attest)
7373
74- ```
74+ ``` text
7575--attest=type=sbom,...
7676--attest=type=provenance,...
7777```
@@ -98,7 +98,7 @@ BuildKit currently supports:
9898
9999### <a name =" allow " ></a > Allow extra privileged entitlement (--allow)
100100
101- ```
101+ ``` text
102102--allow=ENTITLEMENT
103103```
104104
@@ -109,9 +109,7 @@ Allow extra privileged entitlement. List of entitlements:
109109 [ related Dockerfile extensions] ( https://docs.docker.com/engine/reference/builder/#run---securitysandbox ) .
110110
111111For entitlements to be enabled, the ` buildkitd ` daemon also needs to allow them
112- with ` --allow-insecure-entitlement ` (see [ ` create --buildkitd-flags ` ] ( buildx_create.md#buildkitd-flags ) )
113-
114- ** Examples**
112+ with ` --allow-insecure-entitlement ` (see [ ` create --buildkitd-flags ` ] ( buildx_create.md#buildkitd-flags ) ).
115113
116114``` console
117115$ docker buildx create --use --name insecure-builder --buildkitd-flags ' --allow-insecure-entitlement security.insecure'
@@ -122,23 +120,21 @@ $ docker buildx build --allow security.insecure .
122120
123121Same as [ ` docker build ` command] ( https://docs.docker.com/engine/reference/commandline/build/#build-arg ) .
124122
125- There are also useful built-in build args like :
123+ There are also useful built-in build arguments, such as :
126124
127- * ` BUILDKIT_CONTEXT_KEEP_GIT_DIR=<bool> ` trigger git context to keep the ` .git ` directory
128- * ` BUILDKIT_INLINE_CACHE=<bool> ` inline cache metadata to image config or not
129- * ` BUILDKIT_MULTI_PLATFORM=<bool> ` opt into deterministic output regardless of multi-platform output or not
125+ * ` BUILDKIT_CONTEXT_KEEP_GIT_DIR=<bool> ` : trigger git context to keep the ` .git ` directory
126+ * ` BUILDKIT_INLINE_CACHE=<bool> ` : inline cache metadata to image config or not
127+ * ` BUILDKIT_MULTI_PLATFORM=<bool> ` : opt into deterministic output regardless of multi-platform output or not
130128
131129``` console
132130$ docker buildx build --build-arg BUILDKIT_MULTI_PLATFORM=1 .
133131```
134132
135- > ** Note**
136- >
137- > More built-in build args can be found in [ Dockerfile reference docs] ( https://docs.docker.com/engine/reference/builder/#buildkit-built-in-build-args ) .
133+ Learn more about the built-in build arguments in the [ Dockerfile reference docs] ( https://docs.docker.com/engine/reference/builder/#buildkit-built-in-build-args ) .
138134
139135### <a name =" build-context " ></a > Additional build contexts (--build-context)
140136
141- ```
137+ ``` text
142138--build-context=name=VALUE
143139```
144140
@@ -166,7 +162,7 @@ FROM alpine
166162COPY --from=project myfile /
167163```
168164
169- #### <a name =" source-oci-layout " ></a > Source image from OCI layout directory
165+ #### <a name =" source-oci-layout " ></a > Use an OCI layout directory as build context
170166
171167Source an image from a local [ OCI layout compliant directory] ( https://github.com/opencontainers/image-spec/blob/main/image-layout.md ) ,
172168either by tag, or by digest:
@@ -194,7 +190,7 @@ Same as [`buildx --builder`](buildx.md#builder).
194190
195191### <a name =" cache-from " ></a > Use an external cache source for a build (--cache-from)
196192
197- ```
193+ ``` text
198194--cache-from=[NAME|type=TYPE[,KEY=VALUE]]
199195```
200196
@@ -230,7 +226,7 @@ More info about cache exporters and available attributes: https://github.com/mob
230226
231227### <a name =" cache-to " ></a > Export build cache to an external cache destination (--cache-to)
232228
233- ```
229+ ``` text
234230--cache-to=[NAME|type=TYPE[,KEY=VALUE]]
235231```
236232
@@ -247,9 +243,8 @@ Export build cache to an external cache destination. Supported types are
247243- [ ` s3 ` type] ( https://github.com/moby/buildkit#s3-cache-experimental ) exports
248244 cache to a S3 bucket.
249245
250- ` docker ` driver currently only supports exporting inline cache metadata to image
251- configuration. Alternatively, ` --build-arg BUILDKIT_INLINE_CACHE=1 ` can be used
252- to trigger inline cache exporter.
246+ The ` docker ` driver only supports cache exports using the ` inline ` and ` local `
247+ cache backends.
253248
254249Attribute key:
255250
@@ -283,6 +278,7 @@ directory of the specified file must already exist and be writable.
283278$ docker buildx build --load --metadata-file metadata.json .
284279$ cat metadata.json
285280```
281+
286282``` json
287283{
288284 "containerimage.config.digest" : " sha256:2937f66a9722f7f4a2df583de2f8cb97fc9196059a410e7f00072fc918930e66" ,
@@ -301,14 +297,14 @@ $ cat metadata.json
301297
302298### <a name =" output " ></a > Set the export action for the build result (-o, --output)
303299
304- ```
300+ ``` text
305301-o, --output=[PATH,-,type=TYPE[,KEY=VALUE]
306302```
307303
308304Sets the export action for the build result. In ` docker build ` all builds finish
309305by creating a container image and exporting it to ` docker images ` . ` buildx ` makes
310306this step configurable allowing results to be exported directly to the client,
311- oci image tarballs, registry etc.
307+ OCI image tarballs, registry etc.
312308
313309Buildx with ` docker ` driver currently only supports local, tarball exporter and
314310image exporter. ` docker-container ` driver supports all the exporters.
@@ -363,15 +359,15 @@ The `docker` export type writes the single-platform result image as a [Docker im
363359specification] ( https://github.com/docker/docker/blob/v20.10.2/image/spec/v1.2.md )
364360tarball on the client. Tarballs created by this exporter are also OCI compatible.
365361
366- Currently, multi-platform images cannot be exported with the ` docker ` export type.
367- The most common usecase for multi-platform images is to directly push to a registry
368- ( see [ ` registry ` ] ( #registry ) ).
362+ The default image store in Docker Engine doesn't support loading multi-platform
363+ images. You can enable the containerd image store, or push multi-platform images
364+ is to directly push to a registry, see [ ` registry ` ] ( #registry ) .
369365
370366Attribute keys:
371367
372- - ` dest ` - destination path where tarball will be written. If not specified the
373- tar will be loaded automatically to the current docker instance .
374- - ` context ` - name for the docker context where to import the result
368+ - ` dest ` - destination path where tarball will be written. If not specified,
369+ the tar will be loaded automatically to the local image store .
370+ - ` context ` - name for the Docker context where to import the result
375371
376372#### ` image `
377373
@@ -382,15 +378,15 @@ can be automatically pushed to a registry by specifying attributes.
382378Attribute keys:
383379
384380- ` name ` - name (references) for the new image.
385- - ` push ` - boolean to automatically push the image.
381+ - ` push ` - Boolean to automatically push the image.
386382
387383#### ` registry `
388384
389385The ` registry ` exporter is a shortcut for ` type=image,push=true ` .
390386
391387### <a name =" platform " ></a > Set the target platforms for the build (--platform)
392388
393- ```
389+ ``` text
394390--platform=value[,value]
395391```
396392
@@ -419,12 +415,12 @@ and `arm` architectures. You can see what runtime platforms your current builder
419415instance supports by running ` docker buildx inspect --bootstrap ` .
420416
421417Inside a ` Dockerfile ` , you can access the current platform value through
422- ` TARGETPLATFORM ` build argument. Please refer to the [ ` docker build `
418+ ` TARGETPLATFORM ` build argument. Refer to the [ ` docker build `
423419documentation] ( https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope )
424420for the full description of automatic platform argument variants .
425421
426- The formatting for the platform specifier is defined in the [ containerd source
427- code] ( https://github.com/containerd/containerd/blob/v1.4.3/platforms/platforms.go#L63 ) .
422+ You can find the formatting definition for the platform specifier in the
423+ [ containerd source code] ( https://github.com/containerd/containerd/blob/v1.4.3/platforms/platforms.go#L63 ) .
428424
429425``` console
430426$ docker buildx build --platform=linux/arm64 .
@@ -434,11 +430,11 @@ $ docker buildx build --platform=darwin .
434430
435431### <a name =" progress " ></a > Set type of progress output (--progress)
436432
437- ```
433+ ``` text
438434--progress=VALUE
439435```
440436
441- Set type of progress output (auto, plain, tty). Use plain to show container
437+ Set type of progress output (` auto ` , ` plain ` , ` tty ` ). Use plain to show container
442438output (default "auto").
443439
444440> ** Note**
@@ -472,15 +468,18 @@ provenance attestations for the build result. For example,
472468` --provenance=mode=max ` can be used as an abbreviation for
473469` --attest=type=provenance,mode=max ` .
474470
475- Additionally, ` --provenance ` can be used with boolean values to broadly enable
476- or disable provenance attestations. For example, ` --provenance=false ` can be
477- used to disable all provenance attestations, while ` --provenance=true ` can be
478- used to enable all provenance attestations.
471+ Additionally, ` --provenance ` can be used with Boolean values to enable or disable
472+ provenance attestations. For example, ` --provenance=false ` disables all provenance attestations,
473+ while ` --provenance=true ` enables all provenance attestations.
479474
480475By default, a minimal provenance attestation will be created for the build
481- result, which will only be attached for images pushed to registries.
476+ result. Note that the default image store in Docker Engine doesn't support
477+ attestations. Provenance attestations only persist for images pushed directly
478+ to a registry if you use the default image store. Alternatively, you can switch
479+ to using the containerd image store.
482480
483- For more information, see [ here] ( https://docs.docker.com/build/attestations/slsa-provenance/ ) .
481+ For more information about provenance attestations, see
482+ [ here] ( https://docs.docker.com/build/attestations/slsa-provenance/ ) .
484483
485484### <a name =" push " ></a > Push the build result to a registry (--push)
486485
@@ -494,15 +493,19 @@ attestations for the build result. For example,
494493` --sbom=generator=<user>/<generator-image> ` can be used as an abbreviation for
495494` --attest=type=sbom,generator=<user>/<generator-image> ` .
496495
497- Additionally, ` --sbom ` can be used with boolean values to broadly enable or
498- disable SBOM attestations. For example, ` --sbom=false ` can be used to disable
499- all SBOM attestations.
496+ Additionally, ` --sbom ` can be used with Boolean values to enable or disable
497+ SBOM attestations. For example, ` --sbom=false ` disables all SBOM attestations.
498+
499+ Note that the default image store in Docker Engine doesn't support
500+ attestations. Provenance attestations only persist for images pushed directly
501+ to a registry if you use the default image store. Alternatively, you can switch
502+ to using the containerd image store.
500503
501504For more information, see [ here] ( https://docs.docker.com/build/attestations/sbom/ ) .
502505
503506### <a name =" secret " ></a > Secret to expose to the build (--secret)
504507
505- ```
508+ ``` text
506509--secret=[type=TYPE[,KEY=VALUE]
507510```
508511
@@ -515,7 +518,7 @@ If `type` is unset it will be detected. Supported types are:
515518
516519Attribute keys:
517520
518- - ` id ` - ID of the secret. Defaults to basename of the ` src ` path.
521+ - ` id ` - ID of the secret. Defaults to base name of the ` src ` path.
519522- ` src ` , ` source ` - Secret filename. ` id ` used if unset.
520523
521524``` dockerfile
@@ -557,7 +560,7 @@ optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g`
557560
558561### <a name =" ssh " ></a > SSH agent socket or keys to expose to the build (--ssh)
559562
560- ```
563+ ``` text
561564--ssh=default|<id>[=<socket>|<key>[,<key>]]
562565```
563566
@@ -597,6 +600,6 @@ $ docker buildx build --ulimit nofile=1024:1024 .
597600
598601> ** Note**
599602>
600- > If you do not provide a ` hard limit ` , the ` soft limit ` is used
601- > for both values. If no ` ulimits ` are set, they are inherited from
603+ > If you don't provide a ` hard limit ` , the ` soft limit ` is used
604+ > for both values. If no ` ulimits ` are set, they're inherited from
602605> the default ` ulimits ` set on the daemon.
0 commit comments