Fixes #18571
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -1170,12 +1170,17 @@ func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) {
|
| 1170 | 1170 |
} |
| 1171 | 1171 |
} |
| 1172 | 1172 |
|
| 1173 |
+ comment := img.Comment |
|
| 1174 |
+ if len(comment) == 0 && len(img.History) > 0 {
|
|
| 1175 |
+ comment = img.History[len(img.History)-1].Comment |
|
| 1176 |
+ } |
|
| 1177 |
+ |
|
| 1173 | 1178 |
imageInspect := &types.ImageInspect{
|
| 1174 | 1179 |
ID: img.ID().String(), |
| 1175 | 1180 |
RepoTags: repoTags, |
| 1176 | 1181 |
RepoDigests: repoDigests, |
| 1177 | 1182 |
Parent: img.Parent.String(), |
| 1178 |
- Comment: img.Comment, |
|
| 1183 |
+ Comment: comment, |
|
| 1179 | 1184 |
Created: img.Created.Format(time.RFC3339Nano), |
| 1180 | 1185 |
Container: img.Container, |
| 1181 | 1186 |
ContainerConfig: &img.ContainerConfig, |
| ... | ... |
@@ -372,3 +372,12 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *check.C) {
|
| 372 | 372 |
c.Assert(out, checker.Not(checker.Contains), "not-shown") |
| 373 | 373 |
c.Assert(out, checker.Contains, "Error: No such container: missing") |
| 374 | 374 |
} |
| 375 |
+ |
|
| 376 |
+func (s *DockerSuite) TestInspectHistory(c *check.C) {
|
|
| 377 |
+ dockerCmd(c, "run", "--name=testcont", "-d", "busybox", "top") |
|
| 378 |
+ dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg") |
|
| 379 |
+ out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg")
|
|
| 380 |
+ |
|
| 381 |
+ c.Assert(err, check.IsNil) |
|
| 382 |
+ c.Assert(out, checker.Contains, "test comment") |
|
| 383 |
+} |