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