Merge pull request #1002 from crosbymichael/stopped
Return 0 for pid if container is stopped
This commit is contained in:
commit
91dd6d2452
7
list.go
7
list.go
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"encoding/json"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/opencontainers/runc/libcontainer/utils"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -130,10 +131,14 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pid := state.BaseState.InitProcessPid
|
||||
if containerStatus == libcontainer.Stopped {
|
||||
pid = 0
|
||||
}
|
||||
bundle, annotations := utils.Annotations(state.Config.Labels)
|
||||
s = append(s, containerState{
|
||||
ID: state.BaseState.ID,
|
||||
InitProcessPid: state.BaseState.InitProcessPid,
|
||||
InitProcessPid: pid,
|
||||
Status: containerStatus.String(),
|
||||
Bundle: bundle,
|
||||
Created: state.BaseState.Created,
|
||||
|
|
7
state.go
7
state.go
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/opencontainers/runc/libcontainer/utils"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -55,11 +56,15 @@ instance of a container.`,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pid := state.BaseState.InitProcessPid
|
||||
if containerStatus == libcontainer.Stopped {
|
||||
pid = 0
|
||||
}
|
||||
bundle, annotations := utils.Annotations(state.Config.Labels)
|
||||
cs := cState{
|
||||
Version: state.BaseState.Config.Version,
|
||||
ID: state.BaseState.ID,
|
||||
InitProcessPid: state.BaseState.InitProcessPid,
|
||||
InitProcessPid: pid,
|
||||
Status: containerStatus.String(),
|
||||
Bundle: bundle,
|
||||
Rootfs: state.BaseState.Config.Rootfs,
|
||||
|
|
Loading…
Reference in New Issue