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