summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/main.go14
-rw-r--r--cmd/podman/run.go12
-rw-r--r--cmd/podman/start.go5
3 files changed, 30 insertions, 1 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index b27409e4c..0fd30fa71 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -13,7 +13,10 @@ import (
// This is populated by the Makefile from the VERSION file
// in the repository
-var podmanVersion = ""
+var (
+ podmanVersion = ""
+ exitCode = 125
+)
func main() {
debug := false
@@ -152,5 +155,14 @@ func main() {
} else {
fmt.Fprintln(os.Stderr, err.Error())
}
+ } else {
+ // The exitCode modified from 125, indicates an application
+ // running inside of a container failed, as opposed to the
+ // podman command failed. Must exit with that exit code
+ // otherwise command exited correctly.
+ if exitCode == 125 {
+ exitCode = 0
+ }
}
+ os.Exit(exitCode)
}
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index 654b7a47e..45a428f39 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
+ "strings"
"sync"
"github.com/pkg/errors"
@@ -62,6 +63,11 @@ func runCmd(c *cli.Context) error {
logrus.Debug("new container created ", ctr.ID())
if err := ctr.Init(); err != nil {
+ // This means the command did not exist
+ exitCode = 126
+ if strings.Index(err.Error(), "permission denied") > -1 {
+ exitCode = 127
+ }
return err
}
logrus.Debugf("container storage created for %q", ctr.ID())
@@ -109,9 +115,15 @@ func runCmd(c *cli.Context) error {
}
if createConfig.Detach {
fmt.Printf("%s\n", ctr.ID())
+ exitCode = 0
return nil
}
wg.Wait()
+ if ecode, err := ctr.ExitCode(); err != nil {
+ logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err)
+ } else {
+ exitCode = int(ecode)
+ }
if createConfig.Rm {
return runtime.RemoveContainer(ctr, true)
diff --git a/cmd/podman/start.go b/cmd/podman/start.go
index 33bc354bb..d4ddfbbe7 100644
--- a/cmd/podman/start.go
+++ b/cmd/podman/start.go
@@ -126,6 +126,11 @@ func startCmd(c *cli.Context) error {
fmt.Println(ctr.ID())
}
wg.Wait()
+ if ecode, err := ctr.ExitCode(); err != nil {
+ logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err)
+ } else {
+ exitCode = int(ecode)
+ }
}
return lastError
}