Repository navigation
Commit 569a266
authored
fix(isolation): apply the configured registry to namespaced images (#1759)
## Bug
`docker_isolation.registry` is documented as the custom registry for
isolation images, and air-gapped installs depend on it (see
`isolation_git_image_registry_test.go`). `buildFullImageName` treats any
image containing a `/` as already qualified and returns it unchanged. A
Docker Hub namespaced image such as `myorg/node-mcp:1` therefore
bypasses the configured registry and is pulled from docker.io. The final
`registry + "/" + image` branch is unreachable.
Docker's own rule is that the first path component is a registry host
only if it contains `.` or `:`, or is `localhost`. Otherwise it is a
Docker Hub namespace.
## Trigger
```json
"docker_isolation": {
"enabled": true,
"registry": "mirror.corp",
"default_images": {"node": "myorg/node-mcp:1"}
}
```
A per-server `isolation.image: "myorg/node-mcp:1"` triggers it too.
- Expected image: `mirror.corp/myorg/node-mcp:1`.
- Actual image: `myorg/node-mcp:1`, which a host without internet access
cannot pull.
## Fix
Use Docker's host rule (`imageHasRegistryHost`) to decide whether a
reference is already qualified. With a custom registry configured,
namespaced images get the registry prefix like official images already
do. With no registry configured, `org/image` is still returned
unchanged, so ordinary installs see no difference. Fully qualified
references (`ghcr.io/...`, `localhost:5000/...`,
`registry.local/...@sha256:...`) are untouched.
## Test
`TestBuildFullImageName_ConfiguredRegistryPrefixesNamespacedImages` is a
table test covering the configured-registry and no-registry cases above.
## Commands run
- `CGO_ENABLED=0 go test -count=1 ./internal/upstream/core`: ok
(includes the existing git-image registry tests)
- With the fix reverted (`git stash` of `isolation.go`), the new test
fails with `buildFullImageName("myorg/node-mcp:1") = "myorg/node-mcp:1",
want "mirror.corp/myorg/node-mcp:1"`.
- `gofmt -l` on the edited files: no output1 parent a5c2b1a commit 569a266
2 files changed
Lines changed: 49 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
476 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
477 | 482 | | |
478 | 483 | | |
479 | 484 | | |
| |||
483 | 488 | | |
484 | 489 | | |
485 | 490 | | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
499 | 511 | | |
500 | 512 | | |
501 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments