# `Testcontainers.Docker.Auth`
[🔗](https://github.com/testcontainers/testcontainers-elixir/blob/main/lib/docker/auth.ex#L2)

Resolves Docker registry credentials from the user's Docker config file
(typically `~/.docker/config.json`) and returns a ready-to-send
`X-Registry-Auth` header value.

Scope:

  * Only the `auths` map in `config.json` is supported.
  * Credential helpers (`credsStore`, `credHelpers`) are intentionally out
    of scope — if encountered, a debug log is emitted and `nil` is returned
    so the caller can fall back to anonymous access.

The `DOCKER_CONFIG` environment variable is honoured: when set, the config
file is read from `$DOCKER_CONFIG/config.json`; otherwise the default path
`~/.docker/config.json` is used.

The header value is a URL-safe base64 encoding (without padding) of a JSON
document describing the credentials, as specified by the Docker Engine API.

# `registry_for_image`

```elixir
@spec registry_for_image(String.t()) :: String.t()
```

Returns the registry key that should be used for looking up credentials
for the given `image` (Docker config convention).

Unnamespaced or explicitly `docker.io`-hosted images resolve to
`https://index.docker.io/v1/`; everything else resolves to the registry
host component of the image reference.

# `resolve`

```elixir
@spec resolve(String.t(), String.t() | nil) :: String.t() | nil
```

Resolves registry credentials for the given `image` and returns the
ready-to-send `X-Registry-Auth` header value, or `nil` if no matching
credentials can be found.

`config_path` may be `nil`, in which case the default lookup logic is used
(respecting the `DOCKER_CONFIG` environment variable).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
