Skip to content

Commit 5087e8c

Browse files
committed
Merge pull request moby#17180 from rhatdan/destroy
Docker is calling cont.Destroy twice on success
2 parents b21f95c + 0c518b6 commit 5087e8c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

daemon/execdriver/native/driver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ type execOutput struct {
132132
// Run implements the exec driver Driver interface,
133133
// it calls libcontainer APIs to run a container.
134134
func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execdriver.Hooks) (execdriver.ExitStatus, error) {
135+
destroyed := false
135136
// take the Command and populate the libcontainer.Config from it
136137
container, err := d.createContainer(c, hooks)
137138
if err != nil {
@@ -157,7 +158,9 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
157158
d.activeContainers[c.ID] = cont
158159
d.Unlock()
159160
defer func() {
160-
cont.Destroy()
161+
if !destroyed {
162+
cont.Destroy()
163+
}
161164
d.cleanContainer(c.ID)
162165
}()
163166

@@ -191,6 +194,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
191194
ps = execErr.ProcessState
192195
}
193196
cont.Destroy()
197+
destroyed = true
194198
_, oomKill := <-oom
195199
return execdriver.ExitStatus{ExitCode: utils.ExitStatus(ps.Sys().(syscall.WaitStatus)), OOMKilled: oomKill}, nil
196200
}

0 commit comments

Comments
 (0)