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