Blame containers-auth.json.5.md

8b8f89c
% containers-auth.json 5
dc5d922
dc5d922
# NAME
dc5d922
containers-auth.json - syntax for the registry authentication file
dc5d922
dc5d922
# DESCRIPTION
dc5d922
95ab15e
A file in JSON format controlling authentication against container image registries.
dc5d922
The primary (read/write) file is stored at `${XDG_RUNTIME_DIR}/containers/auth.json` on Linux;
dc5d922
on Windows and macOS, at `$HOME/.config/containers/auth.json`.
dc5d922
dc5d922
When searching for the credential for a registry, the following files will be read in sequence until the valid credential is found:
dc5d922
first reading the primary (read/write) file, or the explicit override using an option of the calling application.
95ab15e
If credentials are not present there,
95ab15e
the search continues in `${XDG_CONFIG_HOME}/containers/auth.json` (usually `~/.config/containers/auth.json`), `$HOME/.docker/config.json`, `$HOME/.dockercfg`.
dc5d922
95ab15e
Except for the primary (read/write) file, other files are read-only unless the user, using an option of the calling application, explicitly points at it as an override.
dc5d922
dc5d922
dc5d922
## FORMAT
dc5d922
2c5e1f3
The auth.json file stores, or references, credentials that allow the user to authenticate
95ab15e
to container image registries.
95ab15e
It is primarily managed by a `login` command from a container tool such as `podman login`,
95ab15e
`buildah login`, or `skopeo login`.
95ab15e
95ab15e
Each entry contains a single hostname (e.g., `docker.io`) or a namespace (e.g., `quay.io/user/image`) as a key,
95ab15e
and credentials in the form of a base64-encoded string as value of `auth`. The
95ab15e
base64-encoded string contains a concatenation of the username, a colon, and the
95ab15e
password.
95ab15e
95ab15e
When checking for available credentials, the relevant repository is matched
95ab15e
against available keys in its hierarchical order, going from most-specific to least-specific.
95ab15e
For example, an image pull for `my-registry.local/namespace/user/image:latest` will
e7b409f
result in a lookup in `auth.json` in the following order:
fcf99dc
fcf99dc
- `my-registry.local/namespace/user/image`
fcf99dc
- `my-registry.local/namespace/user`
fcf99dc
- `my-registry.local/namespace`
fcf99dc
- `my-registry.local`
fcf99dc
fcf99dc
This way it is possible to setup multiple credentials for a single registry
fcf99dc
which can be distinguished by their path.
dc5d922
dc5d922
The following example shows the values found in auth.json after the user logged in to
dc5d922
their accounts on quay.io and docker.io:
dc5d922
dc5d922
```
dc5d922
{
dc5d922
	"auths": {
dc5d922
		"docker.io": {
dc5d922
			"auth": "erfi7sYi89234xJUqaqxgmzcnQ2rRFWM5aJX0EC="
dc5d922
		},
dc5d922
		"quay.io": {
dc5d922
			"auth": "juQAqGmz5eR1ipzx8Evn6KGdw8fEa1w5MWczmgY="
dc5d922
		}
dc5d922
	}
dc5d922
}
dc5d922
```
dc5d922
fcf99dc
This example demonstrates how to use multiple paths for a single registry, while
fcf99dc
preserving a fallback for `my-registry.local`:
fcf99dc
fcf99dc
```
fcf99dc
{
fcf99dc
	"auths": {
fcf99dc
		"my-registry.local/foo/bar/image": {
fcf99dc
			"auth": "…"
fcf99dc
		},
fcf99dc
		"my-registry.local/foo": {
fcf99dc
			"auth": "…"
fcf99dc
		},
fcf99dc
		"my-registry.local": {
fcf99dc
			"auth": "…"
fcf99dc
		},
fcf99dc
	}
fcf99dc
}
fcf99dc
```
fcf99dc
dc5d922
An entry can be removed by using a `logout` command from a container
dc5d922
tool such as `podman logout` or `buildah logout`.
dc5d922
95ab15e
In addition, credential helpers can be configured for specific registries, and the credentials-helper
95ab15e
software can be used to manage the credentials more securely than storing only base64-encoded credentials in `auth.json`.
dc5d922
dc5d922
When the credential helper is in use on a Linux platform, the auth.json file would contain keys that specify the registry domain, and values that specify the suffix of the program to use (i.e. everything after docker-credential-).  For example:
dc5d922
dc5d922
```
dc5d922
{
dc5d922
    "auths": {
dc5d922
        "localhost:5001": {}
dc5d922
    },
dc5d922
    "credHelpers": {
dc5d922
		"registry.example.com": "secretservice"
dc5d922
	}
dc5d922
}
dc5d922
```
dc5d922
dc5d922
For more information on credential helpers, please reference the [GitHub docker-credential-helpers project](https://github.com/docker/docker-credential-helpers/releases).
dc5d922
dc5d922
# SEE ALSO
dc5d922
    buildah-login(1), buildah-logout(1), podman-login(1), podman-logout(1), skopeo-login(1), skopeo-logout(1)
dc5d922
dc5d922
# HISTORY
dc5d922
Feb 2020, Originally compiled by Tom Sweeney <tsweeney@redhat.com>