Fixes: #13579
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
... | ... |
@@ -42,6 +42,7 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON |
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
containerState := &types.ContainerState{ |
45 |
+ Status: container.State.StateString(), |
|
45 | 46 |
Running: container.State.Running, |
46 | 47 |
Paused: container.State.Paused, |
47 | 48 |
Restarting: container.State.Restarting, |
... | ... |
@@ -425,8 +425,9 @@ Return low-level information on the container `id` |
425 | 425 |
"Paused": false, |
426 | 426 |
"Pid": 0, |
427 | 427 |
"Restarting": false, |
428 |
- "Running": false, |
|
429 |
- "StartedAt": "2015-01-06T15:47:32.072697474Z" |
|
428 |
+ "Running": true, |
|
429 |
+ "StartedAt": "2015-01-06T15:47:32.072697474Z", |
|
430 |
+ "Status": "running" |
|
430 | 431 |
}, |
431 | 432 |
"Mounts": [ |
432 | 433 |
{ |
... | ... |
@@ -2159,6 +2160,7 @@ Return low-level information about the `exec` command `id`. |
2159 | 2159 |
"OpenStdout" : false, |
2160 | 2160 |
"Container" : { |
2161 | 2161 |
"State" : { |
2162 |
+ "Status" : "running", |
|
2162 | 2163 |
"Running" : true, |
2163 | 2164 |
"Paused" : false, |
2164 | 2165 |
"Restarting" : false, |
... | ... |
@@ -47,6 +47,38 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) { |
47 | 47 |
dockerCmd(c, "inspect", "busybox") |
48 | 48 |
} |
49 | 49 |
|
50 |
+func (s *DockerSuite) TestInspectStatus(c *check.C) { |
|
51 |
+ out, _ := dockerCmd(c, "run", "-d", "busybox", "top") |
|
52 |
+ out = strings.TrimSpace(out) |
|
53 |
+ |
|
54 |
+ inspectOut, err := inspectField(out, "State.Status") |
|
55 |
+ c.Assert(err, check.IsNil) |
|
56 |
+ if inspectOut != "running" { |
|
57 |
+ c.Fatalf("inspect got wrong status, got: %q, expected: running", inspectOut) |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ dockerCmd(c, "pause", out) |
|
61 |
+ inspectOut, err = inspectField(out, "State.Status") |
|
62 |
+ c.Assert(err, check.IsNil) |
|
63 |
+ if inspectOut != "paused" { |
|
64 |
+ c.Fatalf("inspect got wrong status, got: %q, expected: paused", inspectOut) |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ dockerCmd(c, "unpause", out) |
|
68 |
+ inspectOut, err = inspectField(out, "State.Status") |
|
69 |
+ c.Assert(err, check.IsNil) |
|
70 |
+ if inspectOut != "running" { |
|
71 |
+ c.Fatalf("inspect got wrong status, got: %q, expected: running", inspectOut) |
|
72 |
+ } |
|
73 |
+ |
|
74 |
+ dockerCmd(c, "stop", out) |
|
75 |
+ inspectOut, err = inspectField(out, "State.Status") |
|
76 |
+ c.Assert(err, check.IsNil) |
|
77 |
+ if inspectOut != "exited" { |
|
78 |
+ c.Fatalf("inspect got wrong status, got: %q, expected: exited", inspectOut) |
|
79 |
+ } |
|
80 |
+} |
|
81 |
+ |
|
50 | 82 |
func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) { |
51 | 83 |
|
52 | 84 |
//Both the container and image are named busybox. docker inspect will fetch container |