From 0c518b6ab2b2ed481f7f7da3e38f5f2becfc5b2f Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Mon, 19 Oct 2015 14:53:55 -0400 Subject: [PATCH] Docker is calling cont.Destroy twice on success Signed-off-by: Dan Walsh --- daemon/execdriver/native/driver.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index 94f200a311..09171c56dd 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -132,6 +132,7 @@ type execOutput struct { // Run implements the exec driver Driver interface, // it calls libcontainer APIs to run a container. func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execdriver.Hooks) (execdriver.ExitStatus, error) { + destroyed := false // take the Command and populate the libcontainer.Config from it container, err := d.createContainer(c, hooks) if err != nil { @@ -157,7 +158,9 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd d.activeContainers[c.ID] = cont d.Unlock() defer func() { - cont.Destroy() + if !destroyed { + cont.Destroy() + } d.cleanContainer(c.ID) }() @@ -191,6 +194,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd ps = execErr.ProcessState } cont.Destroy() + destroyed = true _, oomKill := <-oom return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil }