mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
Merge pull request #15023 from hqhq/hq_add_status_in_inspect
Add status string to State field for inspect
This commit is contained in:
@@ -227,6 +227,7 @@ type ExecStartCheck struct {
|
|||||||
// ContainerState stores container's running state
|
// ContainerState stores container's running state
|
||||||
// it's part of ContainerJSONBase and will return by "inspect" command
|
// it's part of ContainerJSONBase and will return by "inspect" command
|
||||||
type ContainerState struct {
|
type ContainerState struct {
|
||||||
|
Status string
|
||||||
Running bool
|
Running bool
|
||||||
Paused bool
|
Paused bool
|
||||||
Restarting bool
|
Restarting bool
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
|
|||||||
}
|
}
|
||||||
|
|
||||||
containerState := &types.ContainerState{
|
containerState := &types.ContainerState{
|
||||||
|
Status: container.State.StateString(),
|
||||||
Running: container.State.Running,
|
Running: container.State.Running,
|
||||||
Paused: container.State.Paused,
|
Paused: container.State.Paused,
|
||||||
Restarting: container.State.Restarting,
|
Restarting: container.State.Restarting,
|
||||||
|
|||||||
@@ -437,8 +437,9 @@ Return low-level information on the container `id`
|
|||||||
"Paused": false,
|
"Paused": false,
|
||||||
"Pid": 0,
|
"Pid": 0,
|
||||||
"Restarting": false,
|
"Restarting": false,
|
||||||
"Running": false,
|
"Running": true,
|
||||||
"StartedAt": "2015-01-06T15:47:32.072697474Z"
|
"StartedAt": "2015-01-06T15:47:32.072697474Z",
|
||||||
|
"Status": "running"
|
||||||
},
|
},
|
||||||
"Mounts": [
|
"Mounts": [
|
||||||
{
|
{
|
||||||
@@ -2176,6 +2177,7 @@ Return low-level information about the `exec` command `id`.
|
|||||||
"OpenStdout" : false,
|
"OpenStdout" : false,
|
||||||
"Container" : {
|
"Container" : {
|
||||||
"State" : {
|
"State" : {
|
||||||
|
"Status" : "running",
|
||||||
"Running" : true,
|
"Running" : true,
|
||||||
"Paused" : false,
|
"Paused" : false,
|
||||||
"Restarting" : false,
|
"Restarting" : false,
|
||||||
|
|||||||
@@ -49,6 +49,38 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
|
|||||||
dockerCmd(c, "inspect", "busybox")
|
dockerCmd(c, "inspect", "busybox")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestInspectStatus(c *check.C) {
|
||||||
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
||||||
|
out = strings.TrimSpace(out)
|
||||||
|
|
||||||
|
inspectOut, err := inspectField(out, "State.Status")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
if inspectOut != "running" {
|
||||||
|
c.Fatalf("inspect got wrong status, got: %q, expected: running", inspectOut)
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerCmd(c, "pause", out)
|
||||||
|
inspectOut, err = inspectField(out, "State.Status")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
if inspectOut != "paused" {
|
||||||
|
c.Fatalf("inspect got wrong status, got: %q, expected: paused", inspectOut)
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerCmd(c, "unpause", out)
|
||||||
|
inspectOut, err = inspectField(out, "State.Status")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
if inspectOut != "running" {
|
||||||
|
c.Fatalf("inspect got wrong status, got: %q, expected: running", inspectOut)
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerCmd(c, "stop", out)
|
||||||
|
inspectOut, err = inspectField(out, "State.Status")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
if inspectOut != "exited" {
|
||||||
|
c.Fatalf("inspect got wrong status, got: %q, expected: exited", inspectOut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
|
func (s *DockerSuite) TestInspectTypeFlagContainer(c *check.C) {
|
||||||
|
|
||||||
//Both the container and image are named busybox. docker inspect will fetch container
|
//Both the container and image are named busybox. docker inspect will fetch container
|
||||||
|
|||||||
Reference in New Issue
Block a user