@@ -1479,7 +1479,9 @@ func (cli *DockerCli) CmdRun(args ...string) error {
if err != nil {
return err
}
- os.Exit(status)
+ if status != 0 {
+ return &utils.StatusError{status}
+ }
return nil
@@ -75,6 +75,9 @@ func main() {
protoAddrParts := strings.SplitN(flHosts[0], "://", 2)
if err := docker.ParseCommands(protoAddrParts[0], protoAddrParts[1], flag.Args()...); err != nil {
+ if sterr, ok := err.(*utils.StatusError); ok {
+ os.Exit(sterr.Status)
log.Fatal(err)
os.Exit(-1)
@@ -1012,3 +1012,12 @@ func (graph *DependencyGraph) GenerateTraversalMap() ([][]string, error) {
return result, nil
+
+// An StatusError reports an unsuccessful exit by a command.
+type StatusError struct {
+ Status int
+}
+func (e *StatusError) Error() string {
+ return fmt.Sprintf("Status: %d", e.Status)