diff --git a/content/manuals/build/building/registry-auth.md b/content/manuals/build/building/registry-auth.md new file mode 100644 index 0000000000..4a190540d7 --- /dev/null +++ b/content/manuals/build/building/registry-auth.md @@ -0,0 +1,67 @@ +--- +title: Registry authentication +description: Select registry credentials by repository and scope for builds +keywords: build, buildx, registry, authentication, credentials, login, scope +weight: 35 +--- + +Buildx uses Docker's credential configuration to authenticate when pulling +images for a build and pushing build results. Sign in to the registry before +building: + +```console +$ docker login registry.example.com +``` + +See the [`docker login` reference](/reference/cli/docker/login/) for credential +stores and authentication methods. + +## Select credentials by repository and scope + +Buildx can load separate Docker credential configurations for specific +registry repositories and token scopes. Use this when a build needs different +credentials for repositories on the same registry, or for pull and push +requests. + +Store each Docker `config.json` in a directory under +`$BUILDX_CONFIG/config/[/][@[,...]]`. +If `BUILDX_CONFIG` isn't set, use the +[config directory lookup order](./variables.md#buildx_config). Repository +paths must match the full repository name. Scopes are registry token actions, +such as `pull` and `push`. + +For example, the default config directory can contain: + +```text +~/.docker/buildx/config/ +└── registry.example.com/ + └── team/ + ├── app@pull/ + │ └── config.json + └── app@pull,push/ + └── config.json +``` + +Populate these files with Docker credential configurations. For example, use +the Docker CLI's `--config` flag to store credentials in the pull config +directory: + +```console +$ docker --config \ + ~/.docker/buildx/config/registry.example.com/team/app@pull \ + login registry.example.com +``` + +Use a different config directory and credentials for the combined `pull,push` +scope. Buildx prefers repository-specific matches over registry-wide matches, +then prefers the match with more scope actions. Every action in a config's +directory suffix must be present in the requested scope. + +If no alternative matches, Buildx uses the normal Docker credential config. +Alternative matching applies when authentication requests contain a single +repository scope; requests involving multiple repositories use the normal +config. + +This is a Buildx-specific compatibility mechanism. Docker commands don't +automatically select these configs by repository or scope. The `--config` +example only chooses where `docker login` stores credentials. diff --git a/content/manuals/build/building/variables.md b/content/manuals/build/building/variables.md index f709a7cc8c..a106fc17c7 100644 --- a/content/manuals/build/building/variables.md +++ b/content/manuals/build/building/variables.md @@ -554,6 +554,9 @@ Usage: $ export BUILDX_CONFIG=/usr/local/etc ``` +For repository- and scope-specific credentials stored under this directory, +see [Registry authentication](./registry-auth.md). + ### BUILDX_CPU_PROFILE {{< summary-bar feature_name="Buildx CPU profile" >}}