diff options
Diffstat (limited to 'cmd/podman/start.go')
-rw-r--r-- | cmd/podman/start.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd/podman/start.go b/cmd/podman/start.go index 00528d04e..e917d9198 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -96,16 +96,21 @@ func startCmd(c *cli.Context) error { return errors.Wrapf(err, "unable to get container state") } + ctrRunning := ctrState == libpod.ContainerStateRunning + if attach { inputStream := os.Stdin if !c.Bool("interactive") { inputStream = nil } - if ctrState == libpod.ContainerStateRunning { - return attachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.String("detach-keys"), c.BoolT("sig-proxy")) + + // attach to the container and also start it not already running + err = startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.String("detach-keys"), c.Bool("sig-proxy"), !ctrRunning) + if ctrRunning { + return err } - if err := startAttachCtr(ctr, os.Stdout, os.Stderr, inputStream, c.String("detach-keys"), c.Bool("sig-proxy")); err != nil { + if err != nil { return errors.Wrapf(err, "unable to start container %s", ctr.ID()) } @@ -117,7 +122,7 @@ func startCmd(c *cli.Context) error { return ctr.Cleanup() } - if ctrState == libpod.ContainerStateRunning { + if ctrRunning { fmt.Println(ctr.ID()) continue } |