Skip to content

Commit

Permalink
Defer container removal
Browse files Browse the repository at this point in the history
  • Loading branch information
x4204 committed Jul 14, 2024
1 parent 2d7085c commit 5e1d97e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/dag/executor/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func (e *docker) Run() error {
return err
}

defer func() {
if e.autoRemove {
err := cli.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{})
util.LogErr("docker executor: remove container", err)
}
}()

statusCh, errCh := cli.ContainerWait(
ctx, resp.ID, container.WaitConditionNotRunning,
)
Expand All @@ -112,11 +119,6 @@ func (e *docker) Run() error {
_, err = stdcopy.StdCopy(e.stdout, e.stdout, out)
util.LogErr("docker executor: stdcopy", err)

if e.autoRemove {
err := cli.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{})
util.LogErr("docker executor: remove container", err)
}

return nil
}

Expand Down

0 comments on commit 5e1d97e

Please sign in to comment.