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