summaryrefslogtreecommitdiff
path: root/cmd/podman/start.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/start.go')
-rw-r--r--cmd/podman/start.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/cmd/podman/start.go b/cmd/podman/start.go
index 3a606d662..f3639cb23 100644
--- a/cmd/podman/start.go
+++ b/cmd/podman/start.go
@@ -1,14 +1,12 @@
package main
import (
- "encoding/json"
"fmt"
"os"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
- cc "github.com/containers/libpod/pkg/spec"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -30,7 +28,9 @@ var (
startCommand.GlobalFlags = MainGlobalOpts
return startCmd(&startCommand)
},
- Example: "CONTAINER-NAME [CONTAINER-NAME ...]",
+ Example: `podman start --latest
+ podman start 860a4b231279 5421ab43b45
+ podman start --interactive --attach imageID`,
}
)
@@ -107,7 +107,8 @@ func startCmd(c *cliconfig.StartValues) error {
}
// attach to the container and also start it not already running
- err = startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, sigProxy, !ctrRunning)
+ // If the container is in a pod, also set to recursively start dependencies
+ err = startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.DetachKeys, sigProxy, !ctrRunning, ctr.PodID() != "")
if errors.Cause(err) == libpod.ErrDetach {
// User manually detached
// Exit cleanly immediately
@@ -124,31 +125,30 @@ func startCmd(c *cliconfig.StartValues) error {
}
if ecode, err := ctr.Wait(); err != nil {
- logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err)
+ if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ // The container may have been removed
+ // Go looking for an exit file
+ ctrExitCode, err := readExitFile(runtime.GetConfig().TmpDir, ctr.ID())
+ if err != nil {
+ logrus.Errorf("Cannot get exit code: %v", err)
+ exitCode = 127
+ } else {
+ exitCode = ctrExitCode
+ }
+ }
} else {
exitCode = int(ecode)
}
- return ctr.Cleanup(ctx)
+ return nil
}
if ctrRunning {
fmt.Println(ctr.ID())
continue
}
// Handle non-attach start
- if err := ctr.Start(ctx); err != nil {
- var createArtifact cc.CreateConfig
- artifact, artifactErr := ctr.GetArtifact("create-config")
- if artifactErr == nil {
- if jsonErr := json.Unmarshal(artifact, &createArtifact); jsonErr != nil {
- logrus.Errorf("unable to detect if container %s should be deleted", ctr.ID())
- }
- if createArtifact.Rm {
- if rmErr := runtime.RemoveContainer(ctx, ctr, true, false); rmErr != nil {
- logrus.Errorf("unable to remove container %s after it failed to start", ctr.ID())
- }
- }
- }
+ // If the container is in a pod, also set to recursively start dependencies
+ if err := ctr.Start(ctx, ctr.PodID() != ""); err != nil {
if lastError != nil {
fmt.Fprintln(os.Stderr, lastError)
}