Skip to content

Commit c3c4f9e

Browse files
dvdksnclaude
andcommitted
docs: fix hosts.toml examples and improve clarity
Address review feedback from dmcgowan: - Fix "disable push" example to use top-level capabilities field instead of a [host] entry (the [host] section is for mirrors, not the default endpoint) - Fix mirror example to remove redundant [host] entry for the upstream registry; server already handles fallback - Replace "internal registry only" example with a simpler correct approach: set server to the internal registry URL, no [host] entries needed - Add Windows directory name format for registries with ports - Add _default/ directory to the tree and explain its use as a global fallback - Clarify format section: top-level fields vs [host] sections, and that capabilities defaults to all three if not set Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 0ed696e commit c3c4f9e

File tree

1 file changed

+47
-36
lines changed

1 file changed

+47
-36
lines changed

content/manuals/engine/daemon/configure-registry.md

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ Docker Engine reads registry host configuration from the following directory:
2020
| Rootless mode | `~/.config/docker/certs.d/` |
2121

2222
Create a subdirectory for each registry you want to configure. The directory
23-
name must match the registry host as it appears in image references:
23+
name must match the registry host as it appears in image references. On
24+
Windows, replace the colon with underscores for registries that use a
25+
non-standard port, since colons are not valid in Windows directory names:
2426

25-
| Image reference | Directory |
26-
| --------------------------------------- | ---------------------------- |
27-
| `docker.io/myorg/myimage:latest` | `docker.io/` |
28-
| `registry.example.com/myimage:latest` | `registry.example.com/` |
29-
| `registry.example.com:5000/myimage:tag` | `registry.example.com:5000/` |
27+
| Image reference | Directory (Linux) | Directory (Windows) |
28+
| --------------------------------------- | ------------------------------------ | ----------------------------- |
29+
| `docker.io/myorg/myimage:latest` | `docker.io/` | `docker.io\` |
30+
| `registry.example.com/myimage:latest` | `registry.example.com/` | `registry.example.com\` |
31+
| `registry.example.com:5000/myimage:tag` | `registry.example.com:5000/` | `registry.example.com_5000_\` |
3032

3133
Each directory contains a `hosts.toml` file:
3234

3335
```text
3436
/etc/docker/certs.d/
37+
├── _default/
38+
│ └── hosts.toml
3539
├── docker.io/
3640
│ └── hosts.toml
3741
├── registry.example.com/
@@ -40,71 +44,78 @@ Each directory contains a `hosts.toml` file:
4044
└── hosts.toml
4145
```
4246

47+
The `_default/` directory is optional. If present, its `hosts.toml` settings
48+
apply to any registry that doesn't have its own directory. Use it to set a
49+
global mirror or change the default behavior for all registries.
50+
4351
Changes to `hosts.toml` files take effect immediately, without restarting
4452
Docker.
4553

4654
## hosts.toml format
4755

48-
Each `hosts.toml` file configures the behavior for one registry. The `server`
49-
field sets the upstream registry URL. The `[host]` section configures specific
50-
endpoints, including what operations they're allowed to perform using the
51-
`capabilities` field.
56+
Each `hosts.toml` file configures one registry. The file has two levels of
57+
configuration:
58+
59+
- **Top-level fields** — apply to the registry's default endpoint (the server
60+
itself). Common fields are `server`, `capabilities`, `ca`, and `skip_verify`.
61+
- **`[host]` sections** — configure additional endpoints such as mirrors.
62+
Hosts are tried in the order listed before falling back to the `server`.
5263

53-
Valid capabilities are:
64+
The `server` field sets the upstream registry URL. If omitted, Docker uses the
65+
registry name from the image reference.
5466

55-
| Capability | Description |
56-
| ---------- | -------------------- |
57-
| `pull` | Allow pulling images |
58-
| `resolve` | Allow tag resolution |
59-
| `push` | Allow pushing images |
67+
Valid values for `capabilities` are:
68+
69+
| Capability | Description |
70+
| ---------- | --------------------------------- |
71+
| `pull` | Allow pulling images |
72+
| `resolve` | Allow resolving a tag to a digest |
73+
| `push` | Allow pushing images |
74+
75+
If `capabilities` is not set, all three are enabled by default.
6076

6177
## Examples
6278

6379
### Disable push to a registry
6480

65-
To prevent Docker from pushing images to a specific registry, omit `push` from
66-
the capabilities:
81+
To prevent Docker from pushing images to a specific registry, set `capabilities`
82+
at the top level and omit `push`:
6783

6884
```toml {title="/etc/docker/certs.d/docker.io/hosts.toml"}
6985
server = "https://registry-1.docker.io"
70-
71-
[host."https://registry-1.docker.io"]
72-
capabilities = ["pull", "resolve"]
86+
capabilities = ["pull", "resolve"]
7387
```
7488

7589
With this configuration, `docker pull` from Docker Hub works normally, but
7690
`docker push` to Docker Hub returns an error.
7791

7892
### Redirect pulls to a mirror
7993

80-
To route pull traffic through a registry mirror:
94+
To route pull traffic through a registry mirror, add the mirror as a `[host]`
95+
entry. Docker tries the mirror first for pulls and falls back to the upstream
96+
registry if the mirror doesn't have the image.
97+
98+
Pushes always bypass mirrors and go directly to the upstream registry because
99+
the mirror entry only has `pull` and `resolve` capabilities:
81100

82101
```toml {title="/etc/docker/certs.d/docker.io/hosts.toml"}
83102
server = "https://registry-1.docker.io"
84103

85104
[host."https://mirror.example.com"]
86105
capabilities = ["pull", "resolve"]
87-
88-
[host."https://registry-1.docker.io"]
89-
capabilities = ["pull", "resolve", "push"]
90106
```
91107

92-
Docker tries the mirror first for pulls, and falls back to Docker Hub if the
93-
mirror doesn't have the image. Pushes always go to Docker Hub directly.
108+
### Use an internal registry
94109

95-
### Internal registry only
96-
97-
To restrict Docker to only push and pull from an internal registry, and block
98-
access to all public registries:
110+
To route all traffic for a registry namespace through an internal host, set
111+
`server` to the internal registry URL. No `[host]` entries are needed:
99112

100113
```toml {title="/etc/docker/certs.d/docker.io/hosts.toml"}
101-
server = "https://registry-1.docker.io"
102-
103-
[host."https://registry-1.docker.io"]
104-
capabilities = []
114+
server = "https://registry.internal.example.com"
105115
```
106116

107-
With no capabilities, all operations to that registry fail.
117+
With this configuration, Docker sends all push and pull operations for
118+
`docker.io` images to `registry.internal.example.com` instead.
108119

109120
> [!NOTE]
110121
> This configuration controls behavior at the daemon level, not as a security

0 commit comments

Comments
 (0)