-
Notifications
You must be signed in to change notification settings - Fork 8.3k
engine: configure registry push/pull with containerd #24213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dvdksn
wants to merge
2
commits into
docker:main
Choose a base branch
from
dvdksn:disable-push-registry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+146
−0
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| --- | ||
| title: Registry host configuration | ||
| description: Configure per-registry behavior for Docker Engine using hosts.toml files | ||
| keywords: containerd, registry, hosts, push, pull, mirror, configuration, daemon | ||
| weight: 25 | ||
| --- | ||
|
|
||
| When using the [containerd image store](/manuals/engine/storage/containerd.md), | ||
| you can configure per-registry behavior using `hosts.toml` files. This lets | ||
| you restrict push or pull access, redirect traffic to a mirror, or customize | ||
| TLS settings on a per-registry basis. | ||
|
|
||
| ## Configuration directory | ||
|
|
||
| Docker Engine reads registry host configuration from the following directory: | ||
|
|
||
| | Setup | Directory | | ||
| | ------------- | --------------------------- | | ||
| | Regular | `/etc/docker/certs.d/` | | ||
| | Rootless mode | `~/.config/docker/certs.d/` | | ||
|
|
||
| Create a subdirectory for each registry you want to configure. The directory | ||
| name must match the registry host as it appears in image references: | ||
|
|
||
| | Image reference | Directory | | ||
| | --------------------------------------- | ---------------------------- | | ||
| | `docker.io/myorg/myimage:latest` | `docker.io/` | | ||
| | `registry.example.com/myimage:latest` | `registry.example.com/` | | ||
| | `registry.example.com:5000/myimage:tag` | `registry.example.com:5000/` | | ||
|
|
||
| Each directory contains a `hosts.toml` file: | ||
|
|
||
| ```text | ||
| /etc/docker/certs.d/ | ||
| ├── docker.io/ | ||
| │ └── hosts.toml | ||
| ├── registry.example.com/ | ||
| │ └── hosts.toml | ||
| └── registry.example.com:5000/ | ||
| └── hosts.toml | ||
| ``` | ||
|
dvdksn marked this conversation as resolved.
|
||
|
|
||
| Changes to `hosts.toml` files take effect immediately, without restarting | ||
| Docker. | ||
|
|
||
| ## hosts.toml format | ||
|
|
||
| Each `hosts.toml` file configures the behavior for one registry. The `server` | ||
| field sets the upstream registry URL. The `[host]` section configures specific | ||
|
dvdksn marked this conversation as resolved.
Outdated
|
||
| endpoints, including what operations they're allowed to perform using the | ||
| `capabilities` field. | ||
|
|
||
| Valid capabilities are: | ||
|
|
||
| | Capability | Description | | ||
| | ---------- | -------------------- | | ||
| | `pull` | Allow pulling images | | ||
| | `resolve` | Allow tag resolution | | ||
| | `push` | Allow pushing images | | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Disable push to a registry | ||
|
|
||
| To prevent Docker from pushing images to a specific registry, omit `push` from | ||
| the capabilities: | ||
|
|
||
| ```toml {title="/etc/docker/certs.d/docker.io/hosts.toml"} | ||
| server = "https://registry-1.docker.io" | ||
|
|
||
| [host."https://registry-1.docker.io"] | ||
| capabilities = ["pull", "resolve"] | ||
|
dvdksn marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| With this configuration, `docker pull` from Docker Hub works normally, but | ||
| `docker push` to Docker Hub returns an error. | ||
|
|
||
| ### Redirect pulls to a mirror | ||
|
|
||
| To route pull traffic through a registry mirror: | ||
|
|
||
| ```toml {title="/etc/docker/certs.d/docker.io/hosts.toml"} | ||
| server = "https://registry-1.docker.io" | ||
|
|
||
| [host."https://mirror.example.com"] | ||
| capabilities = ["pull", "resolve"] | ||
|
|
||
| [host."https://registry-1.docker.io"] | ||
| capabilities = ["pull", "resolve", "push"] | ||
|
dvdksn marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| Docker tries the mirror first for pulls, and falls back to Docker Hub if the | ||
| mirror doesn't have the image. Pushes always go to Docker Hub directly. | ||
|
|
||
| ### Internal registry only | ||
|
|
||
| To restrict Docker to only push and pull from an internal registry, and block | ||
| access to all public registries: | ||
|
|
||
| ```toml {title="/etc/docker/certs.d/docker.io/hosts.toml"} | ||
| server = "https://registry-1.docker.io" | ||
|
dvdksn marked this conversation as resolved.
Outdated
|
||
|
|
||
| [host."https://registry-1.docker.io"] | ||
| capabilities = [] | ||
| ``` | ||
|
|
||
| With no capabilities, all operations to that registry fail. | ||
|
|
||
| > [!NOTE] | ||
| > This configuration controls behavior at the daemon level, not as a security | ||
| > boundary. Builds, containers, and other mechanisms can still interact with | ||
| > registries. For strict registry access control, consider | ||
| > [Registry Access Management](/manuals/enterprise/security/hardened-desktop/registry-access-management.md) | ||
| > in Docker Business. | ||
|
|
||
| ## Relation to daemon.json registry settings | ||
|
|
||
| Docker daemon also supports registry configuration through `daemon.json` options | ||
| like `insecure-registries` and `registry-mirrors`. These settings interact with | ||
| `hosts.toml` as follows: | ||
|
|
||
| - If a `hosts.toml` file configures **two or more** endpoints for a registry | ||
| (such as a mirror and an upstream fallback), the daemon.json settings for that | ||
| registry are **ignored**. The `hosts.toml` configuration takes full control. | ||
| - If `hosts.toml` is absent or configures only a single endpoint, the | ||
| daemon.json settings are applied on top. | ||
|
|
||
| If you're using `hosts.toml` to configure mirrors for a registry, include all | ||
| TLS and authentication settings in the `hosts.toml` file rather than relying on | ||
| `insecure-registries` in `daemon.json`. | ||
|
|
||
| ## Reference | ||
|
|
||
| For the full `hosts.toml` specification, see the | ||
| [containerd registry hosts documentation](https://github.com/containerd/containerd/blob/main/docs/hosts.md). | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.