If you [create a `docker-container` or `kubernetes` builder](../reference/buildx_create.md) and
have specified certificates for registries in the [BuildKit daemon configuration](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md),
the files will be copied into the container under `/etc/buildkit/certs` and
configuration will be updated to reflect that.
Take the following `buildkitd.toml` configuration that will be used for
pushing an image to this registry using self-signed certificates:
```toml"
debug = true
[registry."myregistry.com"]
ca=["/etc/certs/myregistry.pem"]
[[registry."myregistry.com".keypair]]
key="/etc/certs/myregistry_key.pem"
cert="/etc/certs/myregistry_cert.pem"
```
> `/etc/buildkitd.toml`
Here we have configured a self-signed certificate for `myregistry.com` registry.
Now [create a `docker-container` builder](../reference/buildx_create.md)
that will use this BuildKit configuration:
```console
$ docker buildx create --use \
--name mybuilder \
--driver docker-container \
--config /etc/buildkitd.toml
```
Inspecting the builder container, you can see that buildkitd configuration
You can define a registry mirror to use for your builds by providing a [BuildKit daemon configuration](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md)
while creating a builder with the [`--config` flags](../reference/buildx_create.md#config).
```toml
debug = true
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
```
> `/etc/buildkitd.toml`
> :information_source: `debug = true` has been added to be able to debug requests
in the BuildKit daemon and see if the mirror is effectively used.
Then [create a `docker-container` builder](../reference/buildx_create.md)
that will use this BuildKit configuration:
```console
$ docker buildx create --use \
--name mybuilder \
--driver docker-container \
--config /etc/buildkitd.toml
```
Boot and [inspect `mybuilder`](../reference/buildx_inspect.md):
```console
$ docker buildx inspect --bootstrap
```
Build an image:
```console
$ docker buildx build --load . -f-<<EOF
FROM alpine
RUN echo "hello world"
EOF
```
Now let's check the BuildKit logs in the builder container:
Note: Design of bake command is work in progress, the user experience may change
Note: Design of bake command is work in progress, the user experience may change
based on feedback.
based on feedback.
HCL definition example:
**Example HCL definition**
```hcl
```hcl
group "default" {
group "default" {
@ -870,7 +865,6 @@ target "app" {
Please note that in most cases you should just use a single multi-stage Dockerfile with multiple targets for similar behavior. This case is recommended when you have multiple Dockerfiles that can't be easily merged into one.
Please note that in most cases you should just use a single multi-stage Dockerfile with multiple targets for similar behavior. This case is recommended when you have multiple Dockerfiles that can't be easily merged into one.
| `--iidfile string` | Write the image ID to the file |
| `--iidfile string` | Write the image ID to the file |
| `--label stringArray` | Set metadata for an image |
| `--label stringArray` | Set metadata for an image |
| [`--load`](#load) | Shorthand for `--output=type=docker` |
| [`--load`](#load) | Shorthand for `--output=type=docker` |
| `--metadata-file string` | Write build result metadata to the file |
| [`--metadata-file string`](#metadata-file) | Write build result metadata to the file |
| `--network string` | Set the networking mode for the `RUN` instructions during build |
| `--network string` | Set the networking mode for the `RUN` instructions during build |
| `--no-cache` | Do not use cache when building the image |
| `--no-cache` | Do not use cache when building the image |
| `--no-cache-filter stringArray` | Do not cache specified stages |
| `--no-cache-filter stringArray` | Do not cache specified stages |
@ -39,7 +39,7 @@ Start a build
| `-q`, `--quiet` | Suppress the build output and print image ID on success |
| `-q`, `--quiet` | Suppress the build output and print image ID on success |
| [`--secret stringArray`](#secret) | Secret to expose to the build (format: `id=mysecret[,src=/local/secret]`) |
| [`--secret stringArray`](#secret) | Secret to expose to the build (format: `id=mysecret[,src=/local/secret]`) |
| [`--shm-size bytes`](#shm-size) | Size of `/dev/shm` |
| [`--shm-size bytes`](#shm-size) | Size of `/dev/shm` |
| `--ssh stringArray` | SSH agent socket or keys to expose to the build (format: `default\|<id>[=<socket>\|<key>[,<key>]]`) |
| [`--ssh stringArray`](#ssh) | SSH agent socket or keys to expose to the build (format: `default\|<id>[=<socket>\|<key>[,<key>]]`) |
| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag stringArray`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | Name and optionally a tag (format: `name:tag`) |
| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag stringArray`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | Name and optionally a tag (format: `name:tag`) |
| [`--target string`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | Set the target build stage to build |
| [`--target string`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | Set the target build stage to build |
| [`--ulimit ulimit`](#ulimit) | Ulimit options |
| [`--ulimit ulimit`](#ulimit) | Ulimit options |
@ -58,76 +58,195 @@ here we’ll document a subset of the new flags.
## Examples
## Examples
### <aname="builder"></a> Override the configured builder instance (--builder)
### <aname="allow"></a> Allow extra privileged entitlement (--allow)
Same as [`buildx --builder`](buildx.md#builder).
```
--allow=ENTITLEMENT
```
### <aname="platform"></a> Set the target platforms for the build (--platform)
Allow extra privileged entitlement. List of entitlements:
- `network.host` - Allows executions with host networking.
- `security.insecure` - Allows executions without sandbox. See
Set the target platform for the build. All `FROM` commands inside the Dockerfile
More built-in build args can be found in [dockerfile frontend docs](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#built-in-build-args).
without their own `--platform` flag will pull base images for this platform and
this value will also be the platform of the resulting image. The default value
will be the current platform of the buildkit daemon.
When using `docker-container` driver with `buildx`, this flag can accept multiple
#1 [internal] load build definition from Dockerfile
More info about cache exporters and available attributes: https://github.com/moby/buildkit#export-cache
#1 transferring dockerfile: 227B 0.0s done
#1 DONE 0.1s
#2 [internal] load .dockerignore
### <aname="cache-to"></a> Export build cache to an external cache destination (--cache-to)
#2 transferring context: 129B 0.0s done
#2 DONE 0.0s
```
...
--cache-to=[NAME|type=TYPE[,KEY=VALUE]]
```
Export build cache to an external cache destination. Supported types are
`registry`, `local`, `inline` and `gha`.
- [`registry` type](https://github.com/moby/buildkit#registry-push-image-and-cache-separately) exports build cache to a cache manifest in the registry.
- [`local` type](https://github.com/moby/buildkit#local-directory-1) type
More info about cache exporters and available attributes: https://github.com/moby/buildkit#export-cache
### <aname="cache-to"></a> Export build cache to an external cache destination (--cache-to)
```
```
--cache-to=[NAME|type=TYPE[,KEY=VALUE]]
--platform=value[,value]
```
```
Export build cache to an external cache destination. Supported types are
Set the target platform for the build. All `FROM` commands inside the Dockerfile
`registry`, `local`, `inline` and `gha`.
without their own `--platform` flag will pull base images for this platform and
this value will also be the platform of the resulting image. The default value
- [`registry` type](https://github.com/moby/buildkit#registry-push-image-and-cache-separately) exports build cache to a cache manifest in the registry.
will be the current platform of the buildkit daemon.
- [`local` type](https://github.com/moby/buildkit#local-directory-1) type