de7ddf
% CONTAINERS-REGISTRIES.CONF(5) System-wide registry configuration file
de7ddf
% Brent Baude
de7ddf
% Aug 2017
de7ddf
de7ddf
# NAME
de7ddf
containers-registries.conf - Syntax of System Registry Configuration File
de7ddf
de7ddf
# DESCRIPTION
de7ddf
The CONTAINERS-REGISTRIES configuration file is a system-wide configuration
de7ddf
file for container image registries. The file format is TOML.
de7ddf
de7ddf
Container engines will use the `$HOME/.config/containers/registries.conf` if it exists, otherwise they will use `/etc/containers/registries.conf`
de7ddf
de7ddf
### GLOBAL SETTINGS
de7ddf
de7ddf
`unqualified-search-registries`
de7ddf
: An array of _host_[`:`_port_] registries to try when pulling an unqualified image, in order.
de7ddf
de7ddf
`credential-helpers`
de7ddf
: An array of default credential helpers used as external credential stores.  Note that "containers-auth.json" is a reserved value to use auth files as specified in containers-auth.json(5).  The credential helpers are set to `["containers-auth.json"]` if none are specified.
de7ddf
de7ddf
### NAMESPACED `[[registry]]` SETTINGS
de7ddf
de7ddf
The bulk of the configuration is represented as an array of `[[registry]]`
de7ddf
TOML tables; the settings may therefore differ among different registries
de7ddf
as well as among different namespaces/repositories within a registry.
de7ddf
de7ddf
#### Choosing a `[[registry]]` TOML table
de7ddf
de7ddf
Given an image name, a single `[[registry]]` TOML table is chosen based on its `prefix` field.
de7ddf
de7ddf
`prefix`: A prefix of the user-specified image name, i.e. using one of the following formats:
de7ddf
  - _host_[`:`_port_]
de7ddf
  - _host_[`:`_port_]`/`_namespace_[`/`_namespace_…]
de7ddf
  - _host_[`:`_port_]`/`_namespace_[`/`_namespace_…]`/`_repo_
de7ddf
  - _host_[`:`_port_]`/`_namespace_[`/`_namespace_…]`/`_repo_(`:`_tag|`@`_digest_)
de7ddf
  - [`*.`]_host_
de7ddf
de7ddf
The user-specified image name must start with the specified `prefix` (and continue
de7ddf
with the appropriate separator) for a particular `[[registry]]` TOML table to be
de7ddf
considered; (only) the TOML table with the longest match is used. It can
de7ddf
also include wildcarded subdomains in the format `*.example.com`.
de7ddf
The wildcard should only be present at the beginning as shown in the formats
de7ddf
above. Other cases will not work. For example, `*.example.com` is valid but
de7ddf
`example.*.com`, `*.example.com/foo` and `*.example.com:5000/foo/bar:baz` are not.
de7ddf
de7ddf
As a special case, the `prefix` field can be missing; if so, it defaults to the value
de7ddf
of the `location` field (described below).
de7ddf
de7ddf
#### Per-namespace settings
de7ddf
de7ddf
`insecure`
de7ddf
: `true` or `false`.
de7ddf
By default, container runtimes require TLS when retrieving images from a registry.
de7ddf
If `insecure` is set to `true`, unencrypted HTTP as well as TLS connections with untrusted
de7ddf
certificates are allowed.
de7ddf
de7ddf
`blocked`
de7ddf
: `true` or `false`.
de7ddf
If `true`, pulling images with matching names is forbidden.
de7ddf
de7ddf
#### Remapping and mirroring registries
de7ddf
de7ddf
The user-specified image reference is, primarily, a "logical" image name, always used for naming
de7ddf
the image.  By default, the image reference also directly specifies the registry and repository
de7ddf
to use, but the following options can be used to redirect the underlying accesses
de7ddf
to different registry servers or locations (e.g. to support configurations with no access to the
de7ddf
internet without having to change `Dockerfile`s, or to add redundancy).
de7ddf
de7ddf
`location`
de7ddf
: Accepts the same format as the `prefix` field, and specifies the physical location
de7ddf
of the `prefix`-rooted namespace.
de7ddf
de7ddf
By default, this equal to `prefix` (in which case `prefix` can be omitted and the
de7ddf
`[[registry]]` TOML table can only specify `location`).
de7ddf
de7ddf
Example: Given
de7ddf
```
de7ddf
prefix = "example.com/foo"
de7ddf
location = "internal-registry-for-example.net/bar"
de7ddf
```
de7ddf
requests for the image `example.com/foo/myimage:latest` will actually work with the
de7ddf
`internal-registry-for-example.net/bar/myimage:latest` image.
de7ddf
de7ddf
With a `prefix` containing a wildcard in the format: "*.example.com" for subdomain matching,
de7ddf
the location can be empty. In such a case,
de7ddf
prefix matching will occur, but no reference rewrite will occur. The
de7ddf
original requested image string will be used as-is. But other settings like
de7ddf
`insecure` / `blocked` / `mirrors` will be applied to matching images.
de7ddf
de7ddf
Example: Given
de7ddf
```
de7ddf
prefix = "*.example.com"
de7ddf
```
de7ddf
requests for the image `blah.example.com/foo/myimage:latest` will be used
de7ddf
as-is. But other settings like insecure/blocked/mirrors will be applied to matching images
de7ddf
de7ddf
`mirror`
de7ddf
: An array of TOML tables specifying (possibly-partial) mirrors for the
de7ddf
`prefix`-rooted namespace.
de7ddf
de7ddf
The mirrors are attempted in the specified order; the first one that can be
de7ddf
contacted and contains the image will be used (and if none of the mirrors contains the image,
de7ddf
the primary location specified by the `registry.location` field, or using the unmodified
de7ddf
user-specified reference, is tried last).
de7ddf
de7ddf
Each TOML table in the `mirror` array can contain the following fields, with the same semantics
de7ddf
as if specified in the `[[registry]]` TOML table directly:
de7ddf
- `location`
de7ddf
- `insecure`
de7ddf
de7ddf
`mirror-by-digest-only`
de7ddf
: `true` or `false`.
de7ddf
If `true`, mirrors will only be used during pulling if the image reference includes a digest.
de7ddf
Referencing an image by digest ensures that the same is always used
de7ddf
(whereas referencing an image by a tag may cause different registries to return
de7ddf
different images if the tag mapping is out of sync).
de7ddf
de7ddf
Note that if this is `true`, images referenced by a tag will only use the primary
de7ddf
registry, failing if that registry is not accessible.
de7ddf
de7ddf
*Note*: Redirection and mirrors are currently processed only when reading images, not when pushing
de7ddf
to a registry; that may change in the future.
de7ddf
de7ddf
#### Short-Name Aliasing
de7ddf
The use of unqualified-search registries entails an ambiguity as it is
de7ddf
unclear from which registry a given image, referenced by a short name,
de7ddf
may be pulled from.
de7ddf
de7ddf
As mentioned in the note at the end of this man page, using short names is
de7ddf
subject to the risk of hitting squatted registry namespaces.  If the
de7ddf
unqualified-search registries are set to `["registry1.com", "registry2.com"]`
de7ddf
an attacker may take over a namespace of registry1.com such that an image may
de7ddf
be pulled from registry1.com instead of the intended source registry2.com.
de7ddf
de7ddf
While it is highly recommended to always use fully-qualified image references,
de7ddf
existing deployments using short names may not be easily changed.  To
de7ddf
circumvent the aforementioned ambiguity, so called short-name aliases can be
de7ddf
configured that point to a fully-qualified image
de7ddf
reference.
de7ddf
de7ddf
Short-name aliases can be configured in the `[aliases]` table in the form of
de7ddf
`"name"="value"` with the left-hand `name` being the short name (e.g., "image")
de7ddf
and the right-hand `value` being the fully-qualified image reference (e.g.,
de7ddf
"registry.com/namespace/image").  Note that neither "name" nor "value" can
de7ddf
include a tag or digest.  Moreover, "name" must be a short name and hence
de7ddf
cannot include a registry domain or refer to localhost.
de7ddf
de7ddf
When pulling a short name, the configured aliases table will be used for
de7ddf
resolving the short name.  If a matching alias is found, it will be used
de7ddf
without further consulting the unqualified-search registries list.  If no
de7ddf
matching alias is found, the behavior can be controlled via the
de7ddf
`short-name-mode` option as described below.
de7ddf
de7ddf
Note that tags and digests are stripped off a user-specified short name for
de7ddf
alias resolution.  Hence, "image", "image:tag" and "image@digest" all resolve
de7ddf
to the same alias (i.e., "image").  Stripped off tags and digests are later
de7ddf
appended to the resolved alias.
de7ddf
de7ddf
Further note that drop-in configuration files (see containers-registries.conf.d(5))
de7ddf
can override aliases in the specific loading order of the files.  If the "value" of
de7ddf
an alias is empty (i.e., ""), the alias will be erased.  However, a given
de7ddf
"name" may only be specified once in a single config file.
de7ddf
de7ddf
de7ddf
#### Short-Name Aliasing: Modes
de7ddf
de7ddf
The `short-name-mode` option supports three modes to control the behaviour of
de7ddf
short-name resolution.
de7ddf
de7ddf
* `enforcing`: If only one unqualified-search registry is set, use it as there
de7ddf
  is no ambiguity.  If there is more than one registry and the user program is
de7ddf
  running in a terminal (i.e., stdout & stdin are a TTY), prompt the user to
de7ddf
  select one of the specified search registries.  If the program is not running
de7ddf
  in a terminal, the ambiguity cannot be resolved which will lead to an error.
de7ddf
de7ddf
* `permissive`: Behaves as enforcing but does not lead to an error if the
de7ddf
  program is not running in a terminal.  Instead, fallback to using all
de7ddf
  unqualified-search registries.
de7ddf
de7ddf
* `disabled`: Use all unqualified-search registries without prompting.
de7ddf
de7ddf
If `short-name-mode` is not specified at all or left empty, default to the
de7ddf
`permissive` mode.  If the user-specified short name was not aliased already,
de7ddf
the `enforcing` and `permissive` mode if prompted, will record a new alias
de7ddf
after a successful pull.  Note that the recorded alias will be written to
de7ddf
`/var/cache/containers/short-name-aliases.conf` for root to have a clear
de7ddf
separation between possibly human-edited registries.conf files and the
de7ddf
machine-generated `short-name-aliases-conf`.  Note that `$HOME/.cache` is used
de7ddf
for rootless users.  If an alias is specified in a
de7ddf
`registries.conf` file and also the machine-generated
de7ddf
`short-name-aliases.conf`, the `short-name-aliases.conf` file has precedence.
de7ddf
de7ddf
#### Normalization of docker.io references
de7ddf
de7ddf
The Docker Hub `docker.io` is handled in a special way: every push and pull
de7ddf
operation gets internally normalized with `/library` if no other specific
de7ddf
namespace is defined (for example on `docker.io/namespace/image`).
de7ddf
de7ddf
(Note that the above-described normalization happens to match the behavior of
de7ddf
Docker.)
de7ddf
de7ddf
This means that a pull of `docker.io/alpine` will be internally translated to
de7ddf
`docker.io/library/alpine`. A pull of `docker.io/user/alpine` will not be
de7ddf
rewritten because this is already the correct remote path.
de7ddf
de7ddf
Therefore, to remap or mirror the `docker.io` images in the (implied) `/library`
de7ddf
namespace (or that whole namespace), the prefix and location fields in this
de7ddf
configuration file must explicitly include that `/library` namespace. For
de7ddf
example `prefix = "docker.io/library/alpine"` and not `prefix =
de7ddf
"docker.io/alpine"`. The latter would match the `docker.io/alpine/*`
de7ddf
repositories but not the `docker.io/[library/]alpine` image).
de7ddf
de7ddf
### EXAMPLE
de7ddf
de7ddf
```
de7ddf
unqualified-search-registries = ["example.com"]
de7ddf
de7ddf
[[registry]]
de7ddf
prefix = "example.com/foo"
de7ddf
insecure = false
de7ddf
blocked = false
de7ddf
location = "internal-registry-for-example.com/bar"
de7ddf
de7ddf
[[registry.mirror]]
de7ddf
location = "example-mirror-0.local/mirror-for-foo"
de7ddf
de7ddf
[[registry.mirror]]
de7ddf
location = "example-mirror-1.local/mirrors/foo"
de7ddf
insecure = true
de7ddf
```
de7ddf
Given the above, a pull of `example.com/foo/image:latest` will try:
de7ddf
    1. `example-mirror-0.local/mirror-for-foo/image:latest`
de7ddf
    2. `example-mirror-1.local/mirrors/foo/image:latest`
de7ddf
    3. `internal-registry-for-example.net/bar/image:latest`
de7ddf
de7ddf
in order, and use the first one that exists.
de7ddf
de7ddf
## VERSION 1 FORMAT - DEPRECATED
de7ddf
VERSION 1 format is still supported but it does not support
de7ddf
using registry mirrors, longest-prefix matches, or location rewriting.
de7ddf
de7ddf
The TOML format is used to build a simple list of registries under three
de7ddf
categories: `registries.search`, `registries.insecure`, and `registries.block`.
de7ddf
You can list multiple registries using a comma separated list.
de7ddf
de7ddf
Search registries are used when the caller of a container runtime does not fully specify the
de7ddf
container image that they want to execute.  These registries are prepended onto the front
de7ddf
of the specified container image until the named image is found at a registry.
de7ddf
de7ddf
Note that insecure registries can be used for any registry, not just the registries listed
de7ddf
under search.
de7ddf
de7ddf
The `registries.insecure` and `registries.block` lists have the same meaning as the
de7ddf
`insecure` and `blocked` fields in the current version.
de7ddf
de7ddf
### EXAMPLE
de7ddf
The following example configuration defines two searchable registries, one
de7ddf
insecure registry, and two blocked registries.
de7ddf
de7ddf
```
de7ddf
[registries.search]
de7ddf
registries = ['registry1.com', 'registry2.com']
de7ddf
de7ddf
[registries.insecure]
de7ddf
registries = ['registry3.com']
de7ddf
de7ddf
[registries.block]
de7ddf
registries = ['registry.untrusted.com', 'registry.unsafe.com']
de7ddf
```
de7ddf
de7ddf
# NOTE: RISK OF USING UNQUALIFIED IMAGE NAMES
de7ddf
We recommend always using fully qualified image names including the registry
de7ddf
server (full dns name), namespace, image name, and tag
de7ddf
(e.g., registry.redhat.io/ubi8/ubi:latest). When using short names, there is
de7ddf
always an inherent risk that the image being pulled could be spoofed. For
de7ddf
example, a user wants to pull an image named `foobar` from a registry and
de7ddf
expects it to come from myregistry.com. If myregistry.com is not first in the
de7ddf
search list, an attacker could place a different `foobar` image at a registry
de7ddf
earlier in the search list. The user would accidentally pull and run the
de7ddf
attacker's image and code rather than the intended content. We recommend only
de7ddf
adding registries which are completely trusted, i.e. registries which don't
de7ddf
allow unknown or anonymous users to create accounts with arbitrary names. This
de7ddf
will prevent an image from being spoofed, squatted or otherwise made insecure.
de7ddf
If it is necessary to use one of these registries, it should be added at the
de7ddf
end of the list.
de7ddf
de7ddf
It is recommended to use fully-qualified images for pulling as
de7ddf
the destination registry is unambiguous. Pulling by digest
de7ddf
(i.e., quay.io/repository/name@digest) further eliminates the ambiguity of
de7ddf
tags.
de7ddf
de7ddf
# SEE ALSO
de7ddf
 containers-auth.json(5) containers-certs.d(5)
de7ddf
de7ddf
# HISTORY
de7ddf
Dec 2019, Warning added for unqualified image names by Tom Sweeney <tsweeney@redhat.com>
de7ddf
de7ddf
Mar 2019, Added additional configuration format by Sascha Grunert <sgrunert@suse.com>
de7ddf
de7ddf
Aug 2018, Renamed to containers-registries.conf(5) by Valentin Rothberg <vrothberg@suse.com>
de7ddf
de7ddf
Jun 2018, Updated by Tom Sweeney <tsweeney@redhat.com>
de7ddf
de7ddf
Aug 2017, Originally compiled by Brent Baude <bbaude@redhat.com>