diff --git a/exec.go b/exec.go index a1da4188..528d3ade 100644 --- a/exec.go +++ b/exec.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "os" - "path" "strconv" "strings" @@ -79,19 +78,17 @@ func execProcess(context *cli.Context) (int, error) { if err != nil { return -1, err } - - var ( - detach = context.Bool("detach") - rootfs = container.Config().Rootfs - ) - - p, err := getProcess(context, path.Dir(rootfs)) + detach := context.Bool("detach") + state, err := container.State() + if err != nil { + return -1, err + } + bundle := searchLabels(state.Config.Labels, "bundle") + p, err := getProcess(context, bundle) if err != nil { return -1, err } - return runProcess(container, p, nil, context.String("console"), context.String("pid-file"), detach) - } func getProcess(context *cli.Context, bundle string) (*specs.Process, error) { diff --git a/list.go b/list.go index 643e8c1b..50566f85 100644 --- a/list.go +++ b/list.go @@ -117,20 +117,20 @@ func getContainers(context *cli.Context) ([]containerState, error) { ID: state.BaseState.ID, InitProcessPid: state.BaseState.InitProcessPid, Status: containerStatus.String(), - Bundle: getBundlePath(state.Config.Labels), + Bundle: searchLabels(state.Config.Labels, "bundle"), Created: state.BaseState.Created}) } } return s, nil } -func getBundlePath(labels []string) string { +func searchLabels(labels []string, query string) string { for _, l := range labels { parts := strings.SplitN(l, "=", 2) - if len(parts) < 1 { + if len(parts) < 2 { continue } - if parts[0] == "bundle" { + if parts[0] == query { return parts[1] } }