Skip to content

Keep registry and namespace when re-fetching a manifest list in bin/docker-to-squash.py - #9299

Closed
ToniAdreal wants to merge 1 commit into
apache:masterfrom
ToniAdreal:fix-9290-manifest-ref-registry
Closed

ToniAdreal wants to merge 1 commit into
apache:masterfrom
ToniAdreal:fix-9290-manifest-ref-registry

Conversation

@ToniAdreal

Copy link
Copy Markdown

Fixes #9290.

When skopeo inspect --raw returns a manifest list, get_manifest_from_docker_image in bin/docker-to-squash.py re-fetches the amd64 manifest by digest, but it builds the new reference with

image.split("/", 1)[-1].split(":", 1)[0]

which drops the registry and the namespace. Reproduced on Python 3.12.3 with skopeo stubbed (first answer a manifest list with amd64 digest sha256:bbb222):

  • registry.example.com/team/app:1.0 -> second fetch is docker://team/app@sha256:bbb222 (registry gone)
  • registry.example.com:5000/team/app:1.0 -> docker://team/app@sha256:bbb222 (registry and port gone)
  • myorg/app:1 -> docker://app@sha256:bbb222 (namespace gone, resolves to Docker Hub library/app)

The fix strips only the tag: any digest part is dropped first, then a tag is removed only when the last path component contains a colon, so a registry port is never mistaken for a tag. After the fix the second fetches are docker://registry.example.com/team/app@sha256:bbb222, docker://registry.example.com:5000/team/app@sha256:bbb222, and docker://myorg/app@sha256:bbb222.

Testing: the stubbed repro above was run before and after the change (with calculate_string_hash stubbed in the harness to isolate the reference logic, since its Python 3 failure is #9291). The existing suite also passes against this change (python3 -m unittest test_docker_to_squash.py, with the one-line collections.abc import shim from the #9291 PR in a scratch copy, since the suite cannot be imported on Python 3.10+ until that lands).

This is one of the four docker-to-squash.py fixes #9284 left to separate PRs.

…r-to-squash.py

When skopeo returns a manifest list, get_manifest_from_docker_image re-fetches the amd64 manifest by digest, but it builds the new reference from image.split('/', 1)[-1].split(':', 1)[0], which drops the registry and the namespace: registry.example.com/team/app:1.0 is re-fetched as team/app@<digest>, and myorg/app:1 as app@<digest> (Docker Hub library/app). Strip only the tag instead: drop any digest part first, then remove a tag only when the last path component contains a colon, so a registry port is never mistaken for a tag.

Signed-off-by: ToniAdreal <184365500+ToniAdreal@users.noreply.github.com>
@ToniAdreal

Copy link
Copy Markdown
Author

Closing this as a duplicate. @linzch3 already opened #9294 for #9290 two days ago, covering the same registry/namespace fix. I only spotted it after opening this one, sorry for the noise.

@ToniAdreal ToniAdreal closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker-to-squash.py: re-fetching a multi-arch image drops the registry or namespace

1 participant