From 6672aa74fa7997e10a8d0a5cdbc768031c5a3f47 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 23 Jul 2021 03:45:16 +0200 Subject: [PATCH] cmd/create: Mention that private images require 'podman login' It's not possible to programmatically detect when an image requires logging into the registry [1]. Therefore, instead of trying to handle 'podman pull' failures due to lack of authorization, just mention that private images require 'podman login' and that further details of the failure can be found by using the --verbose option. [1] https://github.com/containers/podman/issues/10858 https://github.com/containers/toolbox/issues/754 https://github.com/containers/toolbox/pull/852 --- src/cmd/create.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/create.go b/src/cmd/create.go index 87c721748..da26fd739 100644 --- a/src/cmd/create.go +++ b/src/cmd/create.go @@ -719,7 +719,13 @@ func pullImage(image, release string) (bool, error) { } if err := podman.Pull(imageFull); err != nil { - return false, fmt.Errorf("failed to pull image %s", imageFull) + var builder strings.Builder + fmt.Fprintf(&builder, "failed to pull image %s\n", imageFull) + fmt.Fprintf(&builder, "If it was a private image, log in with: podman login %s\n", domain) + fmt.Fprintf(&builder, "Use '%s --verbose ...' for further details.", executableBase) + + errMsg := builder.String() + return false, errors.New(errMsg) } return true, nil