Repository navigation
fix(docker): keep the registry host in image row names - #617
Open
17302513901yh-lang wants to merge 1 commit into
Open
17302513901yh-lang wants to merge 1 commit into
17302513901yh-lang wants to merge 1 commit into
Conversation
|
Thanks so much for this, @17302513901yh-lang — the write-up and tests are really clear, especially covering two registries that share a path and a registry with a port. An equivalent fix is already in review in #599. It keeps the registry host on non-Docker-Hub names (including We'll leave this PR open so you can follow along. If you'd like to pick up something else, issues labelled |
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.
Fixes #578.
What changed
parseDockerfileandparseDockerComposedroppedparsed.registrywhen they built the row name, so every image was recorded aslibrary/<image>or<namespace>/<image>. Non-Docker-Hub images were then looked up on Docker Hub under a path that belongs to a different image, and two registries with the same path collapsed into one row.dockerRowName()indocker-cache.ts, used by both parsers, by the cache/manifest key infetchDockerLatestVersion, and by its "only Docker Hub" guard. A registry is kept unless it is a Docker Hub alias (docker.io,index.docker.io,registry-1.docker.io), so Docker Hub names stay exactly as documented.docker-scanner.tsuses it in both parsers.Root cause worth noting:
fetchDockerLatestVersionalready hadif (parsed.registry && parsed.registry !== 'docker.io') return null, but it receives the row name, which no longer contained the registry, so the guard never fired. Keeping the registry in the name is what makes it work, so no extra filtering layer is needed.Tests
test/docker-registry-host.test.ts, 6 cases:ghcr.io/acme/api,mcr.microsoft.com/dotnet/sdk,quay.io/prometheus/node-exporterkeep the registry, staydrift: unknown, and none of them reaches the Docker Hub lookup.docker-compose.yml.nginx:1.27.0andbitnami/redis:7.4.1behave exactly as before (library/nginx,bitnami/redis, driftcurrent).docker.io/library/nginxandindex.docker.io/bitnami/redishave the alias stripped.ghcr.io/acme/apiandquay.io/acme/apistay two rows.localhost:5000/team/appkeeps its port.Note: the
node_modulesin this checkout was incomplete and the package manager install is blocked here, so CI is the first full run of the suite.