matchHost with path does not work for Docker registry credentials #41971
Unanswered
qixiang
asked this question in
Request Help
Replies: 2 comments 2 replies
-
|
the did you tried to include it into your host rules? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How are you running Renovate?
Self-hosted Renovate CLI
Which platform you running Renovate on?
GitLab (.com or self-hosted)
Which version of Renovate are you using?
43.77.0
Please tell us more about your question or problem
Problem
When configuring
hostRuleswith a path-basedmatchHostfor Docker registries (e.g.quay.io/org/repo), the credentials are never applied. This means Renovate cannot access private Docker images when per-repo credentials are required.Example configuration:
This results in:
Why this happens
The https://docs.renovatebot.com/getting-started/private-packages/#host-rules say path-based matchHost is supported:
And the matchHost https://docs.renovatebot.com/configuration-options/#matchhost say:
This works for most datasources because their API URLs share the same path prefix as the
matchHost. For example, npm registry URLs likehttps://registry.company.com/nested/path/packagestart withhttps://registry.company.com/nested/path/.However, the Docker v2 protocol inserts /v2/ as a path prefix in some API URLs, some example:
With the example, the
matchHost(aftermassageHostUrl) ishttps://quay.io/myorg/myrepo.matchesHost()usesstartsWith(), so none of the above API URLs match:"https://quay.io/v2/".startsWith("https://quay.io/myorg/myrepo")returnsfalse.Because no credentials are found,
getAuthHeaders()requests an anonymous token from the registry. The anonymous token lacks pull permissions for private repositories, so the subsequent manifest requests fail with 401.Use case
This matters for container registries (e.g., quay.io) where different repositories may belong to different organizations, each with their own robot account credentials. These repositories are used in a code repository and users need to configure separate credentials per repository, not a single credential for the entire registry.
Proposed fix
Add a fallback credential lookup in
getAuthHeaders()(lib/modules/datasource/docker/common.ts). When the initialhostRules.find()with the API URL returns no credentials, retry with the repository path URL (${registryHost}/${dockerRepository}), which matches the user-configuredmatchHost:The fallback only triggers when the initial lookup returns no credentials.
I have a working implementation with tests in #41967 if the approach is accepted.
Logs (if relevant)
I removed or replaced log lines that irrelevant or related to private data.
Logs
Beta Was this translation helpful? Give feedback.
All reactions