From 4bc25aaea181ca3ccd5aacca862ba6fde20c5b37 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 22 Feb 2016 15:34:41 -0800 Subject: [PATCH] Make sure container is destroyed on error Even in the detach usecase we need to make sure that the contianer is destroyed if there is an error starting the container or anywhere in that workflow. Signed-off-by: Michael Crosby --- start.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/start.go b/start.go index 901a66164..8b7b5446d 100644 --- a/start.go +++ b/start.go @@ -111,5 +111,10 @@ func startContainer(context *cli.Context, spec *specs.LinuxSpec) (int, error) { listenFDs = activation.Files(false) } - return runProcess(container, &spec.Process, listenFDs, context.String("console"), context.String("pid-file"), detach) + status, err := runProcess(container, &spec.Process, listenFDs, context.String("console"), context.String("pid-file"), detach) + if err != nil { + destroy(container) + return -1, err + } + return status, nil }