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