Skip to content

fix: support docker:// URIs with port numbers in registry references#2543

Open
Onyx2406 wants to merge 1 commit intobuildpacks:mainfrom
Onyx2406:fix/registry-ref-with-port
Open

fix: support docker:// URIs with port numbers in registry references#2543
Onyx2406 wants to merge 1 commit intobuildpacks:mainfrom
Onyx2406:fix/registry-ref-with-port

Conversation

@Onyx2406
Copy link
Contributor

@Onyx2406 Onyx2406 commented Mar 7, 2026

Summary

  • Strip the docker:// scheme prefix before passing references to name.ParseReference
  • Fixes docker://localhost:5000/foo/bar being rejected as an invalid locator

Motivation

Fixes #2536 — Docker URIs with port numbers (e.g. docker://localhost:5000/foo/bar) were not recognized as valid PackageLocator references. The go-containerregistry library's name.ParseReference expects bare Docker references without the URI scheme prefix.

Root Cause

In GetLocatorType, when a docker:// URI is detected, the full string including the scheme was passed to name.ParseReference. This works for simple refs like docker://cnbs/some-bp (where docker is interpreted as a registry host), but fails for refs with explicit ports like docker://localhost:5000/foo/bar.

Changes

  • pkg/buildpack/locator_type.go: strings.TrimPrefix(locator, "docker://") before name.ParseReference
  • pkg/buildpack/locator_type_test.go: Add 3 test cases for docker:// URIs with port numbers

Test plan

  • docker://localhost:5000/foo/barPackageLocator
  • docker://localhost:5000/foo/bar:latestPackageLocator
  • docker://myregistry:8080/cnbs/some-bpPackageLocator
  • Existing docker:// tests without ports still pass

Strip the docker:// scheme prefix before passing the reference to
name.ParseReference, which expects bare Docker references like
localhost:5000/foo/bar rather than docker://localhost:5000/foo/bar.

Previously, docker:// URIs with port numbers (e.g.
docker://localhost:5000/foo/bar) were not recognized as valid
PackageLocator references because name.ParseReference failed to
parse the full URI including the scheme prefix.

Fixes buildpacks#2536
@Onyx2406 Onyx2406 requested review from a team as code owners March 7, 2026 18:22
@github-actions github-actions bot added this to the 0.41.0 milestone Mar 7, 2026
@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement Issue that requests a new feature or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

canBeRegistryRef returns falso on registry names with port numbers

1 participant