From 5ad0f0d490d746f256a4b8ab3c38932fb693442d Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 16 Nov 2021 20:16:25 +0100 Subject: [PATCH] Add docker.io to unqualified image name Since that's the default behavior of moby engine, the compat API need to reflect that. Fixes #12320 Signed-off-by: Michael Scherer --- pkg/api/handlers/compat/images.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 0b7ba8bee8..b24624d98f 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -255,6 +255,10 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { // without this early check this function would return 200 but reported error via body stream soon after // it's better to let caller know early via HTTP status code that request cannot be processed _, err := shortnames.Resolve(runtime.SystemContext(), fromImage) + if err != nil && shortnames.IsShortName(fromImage) { + fromImage = fmt.Sprintf("%s/%s", "docker.io", fromImage) + _, err = shortnames.Resolve(runtime.SystemContext(), fromImage) + } if err != nil { utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrap(err, "failed to resolve image name")) return