Repository navigation
fix(docker): never invent a registry host for an image - #2654
Merged
Merged
Conversation
An image reference that names no registry host was stored under an invented one: `FROM nginx` became docker.io/library/nginx, `image: acme/web` docker.io/acme/web, and a local `docker build -t myapp` or a skaffold artifact `image: api` docker.io/library/myapp. docker.io is only Docker's default. Podman and CRI-O resolve a short name through a search list, mirrors rewrite it, and a local build tag may exist on no registry at all. The graph stated a host the code never names. An Image is now the repository as written, tag and digest dropped, with a `registry` property: the host the reference names, else "unknown". A stated host is kept as written; Docker Hub's spellings (docker.io, index.docker.io, registry-1.docker.io) are docker.io, with library/ for an official one-segment name. This holds for every source: FROM and COPY --from, compose services, K8s containers, shell and skaffold build tags, and the per-component Images of a repository built from several Dockerfiles. `FROM nginx` and `image: docker.io/library/nginx` are now two Image nodes. Relating them would state the host again, so the graph does not. The Image QN changes (__image__nginx instead of __image__docker.io/library/nginx), so CBM_INDEX_FORMAT_VERSION moves to 3. Refreshed in place, an older index would give only touched files the new identity and hold both forms of one image; every existing index is rebuilt once on its first index after upgrading. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
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
An image reference that names no registry host was stored under an invented one. The graph then asserted a registry the code never names:
registry)FROM nginx:1.27docker.io/library/nginxnginx(unknown)image: acme/web:1docker.io/acme/webacme/web(unknown)docker build -t myapp:dev svc, skaffoldimage: apidocker.io/library/myapp,docker.io/library/apimyapp,api(unknown)FROM docker.io/redis:7docker.io/library/redisFROM index.docker.io/acme/tooldocker.io/acme/toolFROM ghcr.io/acme/app@sha256:…ghcr.io/acme/appFROM localhost:5000/team/xlocalhost:5000/team/xdocker.io is only Docker's default:
Change
dk_normalize(src/pipeline/pass_docker.c):"unknown".docker.io, withlibrary/for an official one-segment name.registryproperty, including the per-component Images of a repository built from several Dockerfiles.FROM nginxandimage: docker.io/library/nginxare now two Image nodes. Relating them would state the host again, so the graph does not.CBM_INDEX_FORMAT_VERSION2 → 3. The Image QN changes from__image__docker.io/library/nginxto__image__nginx. Refreshed in place, an older index would give only touched files the new identity, and one graph would hold both forms of an image. Shown on a fixture: an unchanged K8s Deployment keptdocker.io/library/nginxwhile the edited Dockerfile got the new name.Release notes: every existing index is rebuilt once on its first index after upgrading. The response reports
"format_migration": true.Smart CI: this repository's own graph changes, because its Dockerfiles' Image names change. The test-impact producer's graph-content digest (
store_content_digest.c) changes with it. The first producer run after this lands is a full refresh, so PRs may get no admitted coverage for about an hour.Proof on real input
17 pinned OSS infra corpora (KKP, gardener, deckhouse, cluster-api, k8s.io, flux, home-ops, microservices-demo, otel-demo, prometheus charts, eks-blueprints, cloud-foundation-fabric, terragrunt, voting-app, awesome-compose, kube-hetzner, kubespray), indexed with a build of
ec6427c3and with this branch:docker.io/…registry: unknown)docker.ioalpine,golang,pythonUpgrade path: a fixture was indexed with the
ec6427c3build (format 2), then once with this branch. The response reportedformat_migration: true, every Image had its new identity with all its edges, anduser_versionwas 3.Tests
probe_image_without_registry_host_stays_unknown(grammar_probe_f) covers every source: Dockerfile FROM (one- and two-segment, docker.io, index.docker.io, ghcr.io, localhost:5000), a K8s container, a compose service, and a shell build tag. It asserts each Image's name andregistry. Onec6427c3every host-less reference readsdocker.io/…with no registry.index_format_v2_images_rebuild_without_invented_host(index_format) rewrites an index into the format-2 image shape, stamps format 2, and re-indexes. It fails without the bump: the index is not routed through the rebuild.grammar_probe_fexpectations change fromdocker.io/…to the name as written. Each change concerns a host-less fixture reference. Every stated host, such asdocker.io/bitnami/kubectl,gcr.io,ghcr.io,quay.ioandregistry.example.com:5000, is unchanged.pipeline_semantic_manifest_reproqueried their host-less fixtures (acme/web-old,acme/demo:*-b) under the docker.io names. Their queries now use the names as written. The routes and counts they assert are unchanged.Verification
Found, not changed here
${IMAGE:-myapp}in a script and DockerfileARGdefaults are expanded. The result no longer gets an invented host, but a build that overrides the default makes a different image.