fix(dind): qualify single-segment refs with tag (alpine:3.20)#71
Merged
Conversation
qualifyDockerHubRef returned the input unchanged for "alpine:3.20"
because its host-detection heuristic looked at the first segment for
either "." or ":" and bailed if either was present — meant to catch
"localhost:5000/foo" and "gcr.io/bar", it also matched the tag colon
in "alpine:3.20".
Downstream, containerd's resolver wraps unqualified refs in "dummy://"
so url.Parse can split them, and url.Parse("dummy://alpine:3.20")
fails with `invalid port ":3.20" after host` — that's the error
showing up as "image alpine:3.20 not found" in `docker run` from dind.
Fix: use the slash as the disambiguator.
- No slash → no path → single-segment name with optional tag/digest.
Always qualifies with docker.io/library/. Covers "alpine",
"alpine:3.20", "alpine@sha256:abc".
- Slash present → segment before the slash is a host candidate, the
existing ".:" or "localhost" check is correct for distinguishing
"localhost:5000/foo" or "gcr.io/bar" from "myorg/myimage".
The test previously documented the broken behavior as a "known
limitation"; replace those assertions with the correct expected
values and add coverage for `alpine:3.20` and `alpine@sha256:...`.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
qualifyDockerHubRef("alpine:3.20")returned the input unchanged, so containerd's resolver then tried to parsealpine:3.20as a host:port reference and failed with:That surfaced inside dind as:
What was wrong
The helper's host-detection looked at the first segment for
.or:and bailed if either was present. The intent was "if you seegcr.io/foo(dot) orlocalhost:5000/foo(colon-port), trust the caller and pass through." But it also matched the tag colon in single-segment refs:.:?alpinealpinedocker.io/library/alpine✓docker.io/library/alpinealpine:3.20alpine:3.20alpine:3.20✗docker.io/library/alpine:3.20myorg/imgmyorgdocker.io/myorg/img✓docker.io/myorg/imglocalhost:5000/xlocalhost:5000localhost:5000/x✓localhost:5000/xThe test in this package even documented the broken behavior as "a known limitation."
Fix
The disambiguator is the slash. If there's no slash, the whole string is a single-segment name with optional
:tagor@digestand should always be qualified withdocker.io/library/. If there's a slash, the part before it is a host candidate and the existing./:/localhostcheck is correct.Test plan
TestQualifyDockerHubRefupdated:alpine:latest→docker.io/library/alpine:latest, plus new cases foralpine:3.20andalpine@sha256:abc123. All 12 sub-cases pass.pkg/dindsuite green (go test -tags containers_image_openpgp ./pkg/dind/...).docker run alpine:3.20inside dind and verify the image is pulled + container starts.Out of scope (filed separately)
When
docker run alpine:3.20succeeds at the image-resolution step, the next failure mode isunable to upgrade to tcp, received 501because dind doesn't implementPOST /containers/{id}/attach(HTTP Upgrade endpoint used bydocker runwithout-d). That's a separate fix tracked on thefix/dind-container-attachbranch — both bugs are in the same Docker CLI invocation but have unrelated root causes.