Skip to content

Commit 8681b3c

Browse files
committed
images: GetImage: touch-up error message for missing platform
Slightly touching up the error message, because the "wanted/actual" output felt too much like a assertion failure in a test-case. - Format the image-reference using "familiar" format, which shows the image's short name for official images. - Move the actual and requested platforms to be a part of the sentence, but within braces. Before this patch: docker image push --platform=linux/amd64 alpine:latest Error response from daemon: image with reference docker.io/library/alpine:latest was found but does not match the specified platform: wanted linux/amd64, actual: linux/riscv64 With this patch: docker image push --platform=linux/amd64 alpine:latest Error response from daemon: image with reference alpine:latest was found but its platform (linux/riscv64) does not match the specified platform (linux/amd64) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d31c241 commit 8681b3c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

daemon/images/image.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,11 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options bac
200200
// This may be confusing.
201201
// The alternative to this is to return an errdefs.Conflict error with a helpful message, but clients will not be
202202
// able to automatically tell what causes the conflict.
203-
retErr = errdefs.NotFound(errors.Errorf("image with reference %s was found but does not match the specified platform: wanted %s, actual: %s", refOrID, platforms.Format(p), platforms.Format(imgPlat)))
203+
imgName := refOrID
204+
if ref, err := reference.ParseNamed(refOrID); err == nil {
205+
imgName = reference.FamiliarString(ref)
206+
}
207+
retErr = errdefs.NotFound(errors.Errorf("image with reference %s was found but its platform (%s) does not match the specified platform (%s)", imgName, platforms.Format(imgPlat), platforms.Format(p)))
204208
}()
205209
ref, err := reference.ParseAnyReference(refOrID)
206210
if err != nil {

0 commit comments

Comments
 (0)