From c6f8e71eeaa1f6fedc2cd6226ffbaab690731435 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Tue, 1 Nov 2022 15:19:37 +0100 Subject: [PATCH] Configure BuildKit page review --- build/buildkit/configure.md | 186 ++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/build/buildkit/configure.md b/build/buildkit/configure.md index 2f8d0999f7..9ea46d5993 100644 --- a/build/buildkit/configure.md +++ b/build/buildkit/configure.md @@ -4,51 +4,56 @@ description: Learn how to configure BuildKit for your builder. keywords: build, buildkit, configuration, buildx, network, cni, registry --- -If you [create a `docker-container` or `kubernetes` builder](../building/drivers/index.md) -with Buildx, you can set a custom [BuildKit configuration](toml-configuration.md) -by passing the [`--config` flag](../../engine/reference/commandline/buildx_create.md#config) -to the [`docker buildx create` command](../../engine/reference/commandline/buildx_create.md): +If you create a `docker-container` or `kubernetes` builder with Buildx, you can +apply a custom [BuildKit configuration](toml-configuration.md) by passing the +[`--config` flag](../../engine/reference/commandline/buildx_create.md#config) to +the `docker buildx create` command. ## Registry mirror -You can define a registry mirror to use for your builds: +You can define a registry mirror to use for your builds. Doing so redirects +BuildKit to pull images from a different hostname. The following steps exemplify +defining a mirror for `docker.io` (Docker Hub) to `mirror.gcr.io`. -```toml -# /etc/buildkitd.toml -debug = true -[registry."docker.io"] - mirrors = ["mirror.gcr.io"] -``` +1. Create a TOML at `/etc/buildkitd.toml` with the following content: -> **Note** -> -> `debug = true` has been added to be able to debug requests -> in the BuildKit daemon and see if the mirror is effectively used. + ```toml + debug = true + [registry."docker.io"] + mirrors = ["mirror.gcr.io"] + ``` -Then [create a `docker-container` builder](../building/drivers/docker-container.md) -that will use this [BuildKit configuration](toml-configuration.md): + > **Note** + > + > `debug = true` turns on debug requests in the BuildKit daemon, which logs a + > message that shows when a mirror is being used. -```console -$ docker buildx create --use --bootstrap \ - --name mybuilder \ - --driver docker-container \ - --config /etc/buildkitd.toml -``` +2. Create a `docker-container` builder that uses this BuildKit configuration: -Build an image: + ```console + $ docker buildx create --use --bootstrap \ + --name mybuilder \ + --driver docker-container \ + --config /etc/buildkitd.toml + ``` -```console -$ docker buildx build --load . -f-< **Note** -> -> Here we use the [CNI config for integration tests in BuildKit](https://github.com/moby/buildkit/blob/master//hack/fixtures/cni.json){:target="_blank" rel="noopener" class="_"}, -> but feel free to use your own config. - -Now build this image: +Now you can build this image, and create a builder instance from it using +[the `--driver-opt image` option](../../engine/reference/commandline/buildx_create.md#driver-opt): ```console $ docker buildx build --tag buildkit-cni:local --load . -``` - -Then [create a `docker-container` builder](../building/drivers/docker-container.md) -that will use this image: - -```console $ docker buildx create --use --bootstrap \ --name mybuilder \ --driver docker-container \