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