Skip to content

Commit fec369f

Browse files
authored
Merge pull request #79 from v2tec/DoNotCallRemoveOnAutoRemove
Do not initiate a RemoveContainer for containers which have AutoRemov…
2 parents b068c62 + 52e73d7 commit fec369f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

container/client.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ func (client dockerClient) StopContainer(c Container, timeout time.Duration) err
101101
// Wait for container to exit, but proceed anyway after the timeout elapses
102102
client.waitForStop(c, timeout)
103103

104-
log.Debugf("Removing container %s", c.ID())
104+
if c.containerInfo.HostConfig.AutoRemove {
105+
log.Debugf("AutoRemove container %s, skipping ContainerRemove call.", c.ID())
106+
} else {
107+
log.Debugf("Removing container %s", c.ID())
105108

106-
if err := client.api.ContainerRemove(bg, c.ID(), types.ContainerRemoveOptions{Force: true, RemoveVolumes: false}); err != nil {
107-
return err
109+
if err := client.api.ContainerRemove(bg, c.ID(), types.ContainerRemoveOptions{Force: true, RemoveVolumes: false}); err != nil {
110+
return err
111+
}
108112
}
109113

110114
// Wait for container to be removed. In this case an error is a good thing

0 commit comments

Comments
 (0)