Fixes: #20709
As discussed in the issue, we need refine the message to
help user more understood, what happened for non-exist image.
Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
... | ... |
@@ -170,6 +170,9 @@ func (is *store) Search(term string) (ID, error) { |
170 | 170 |
|
171 | 171 |
dgst, err := is.digestSet.Lookup(term) |
172 | 172 |
if err != nil { |
173 |
+ if err == digest.ErrDigestNotFound { |
|
174 |
+ err = fmt.Errorf("No such image: %s", term) |
|
175 |
+ } |
|
173 | 176 |
return "", err |
174 | 177 |
} |
175 | 178 |
return ID(dgst), nil |
... | ... |
@@ -167,6 +167,16 @@ func (s *DockerSuite) TestSaveAndLoadRepoFlags(c *check.C) { |
167 | 167 |
c.Assert(before, checker.Equals, after, check.Commentf("inspect is not the same after a save / load")) |
168 | 168 |
} |
169 | 169 |
|
170 |
+func (s *DockerSuite) TestSaveWithNoExistImage(c *check.C) { |
|
171 |
+ testRequires(c, DaemonIsLinux) |
|
172 |
+ |
|
173 |
+ imgName := "foobar-non-existing-image" |
|
174 |
+ |
|
175 |
+ out, _, err := dockerCmdWithError("save", "-o", "test-img.tar", imgName) |
|
176 |
+ c.Assert(err, checker.NotNil, check.Commentf("save image should fail for non-existing image")) |
|
177 |
+ c.Assert(out, checker.Contains, fmt.Sprintf("No such image: %s", imgName)) |
|
178 |
+} |
|
179 |
+ |
|
170 | 180 |
func (s *DockerSuite) TestSaveMultipleNames(c *check.C) { |
171 | 181 |
testRequires(c, DaemonIsLinux) |
172 | 182 |
repoName := "foobar-save-multi-name-test" |