[Bug]: Locally built tag@digest falls back to Docker Hub on create/run
Description
container create / container run do not resolve a locally built tagged image when it is addressed using the standard name:tag@sha256:digest form. The local lookup misses, the reference is normalized to Docker Hub, and the command attempts a remote pull instead.
Raw sha256:<digest> is also misleadingly parsed as an unqualified image name/tag and becomes docker.io/library/sha256:<digest> rather than being rejected or resolved as a local image ID.
Environment
- container CLI 1.1.0 (
5973b9c) - Apple Containerization 0.35.0
- Apple silicon, macOS 26.5.1
- target image platform:
linux/arm64
Reproduction
-
Build an image under a local tag:
container build --platform linux/arm64 --tag local-digest-repro:test . -
Read the locally stored index descriptor digest:
container image inspect local-digest-repro:test -
Confirm tag-based creation works:
container create --name local-digest-repro-by-tag local-digest-repro:test /bin/true -
Delete that stopped container, then try the exact tagged digest reported by inspection:
container create --name local-digest-repro-by-digest \ local-digest-repro:test@sha256:<the-inspected-64-hex-digest> /bin/true
Actual result
The tagged-digest create does not use the local image. It attempts:
https://registry-1.docker.io/v2/library/local-digest-repro/manifests/sha256:<digest>
and fails with a registry response such as:
401 Unauthorized ... no credentials found for host registry-1.docker.io
Supplying raw sha256:<digest> similarly requests:
https://registry-1.docker.io/v2/library/sha256/manifests/<digest>
Expected result
Preferably, create/run should resolve a locally stored image whose descriptor digest matches the supplied named digest, even when the image was originally stored under a tag. At minimum, raw descriptor-digest input should fail with a clear unsupported-reference diagnostic rather than becoming an unrelated Docker Hub repository request.
No registry authentication should be attempted merely because an exact local tagged reference was augmented with the digest reported by container image inspect.
Source-level observation
In 1.1.0, ClientImage._search compares stored reference strings and locally built name annotations, but does not compare the requested digest with the stored descriptor digest:
https://github.com/apple/container/blob/1.1.0/Sources/Services/ContainerAPIService/Client/ClientImage.swift#L220-L245
The reference parser gives the digest precedence for name:tag@digest, producing canonical name@digest and discarding the tag:
https://github.com/apple/containerization/blob/0.35.0/Sources/ContainerizationOCI/Reference.swift#L68-L83 https://github.com/apple/containerization/blob/0.35.0/Sources/ContainerizationOCI/Reference.swift#L139-L147
ClientImage.fetch then pulls after the local lookup returns not found:
https://github.com/apple/container/blob/1.1.0/Sources/Services/ContainerAPIService/Client/ClientImage.swift#L354-L377
Related but not identical: #104 demonstrates that a full named digest reference works when the image was originally pulled/stored under that reference.