Skip to content

Commit

Permalink
Merge pull request #320 from Eun/master
Browse files Browse the repository at this point in the history
close reaper go routines on `DockerContainer.Terminate` & `DockerNetwork.Remove`
  • Loading branch information
Gianluca Arbezzano committed May 21, 2021
2 parents 555d3e6 + 906b5b4 commit b5754a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ func (c *DockerContainer) Start(ctx context.Context) error {

// Terminate is used to kill the container. It is usually triggered by as defer function.
func (c *DockerContainer) Terminate(ctx context.Context) error {
select {
// close reaper if it was created
case c.terminationSignal <- true:
default:
}
err := c.provider.client.ContainerRemove(ctx, c.GetContainerID(), types.ContainerRemoveOptions{
RemoveVolumes: true,
Force: true,
Expand Down Expand Up @@ -421,6 +426,11 @@ type DockerNetwork struct {

// Remove is used to remove the network. It is usually triggered by as defer function.
func (n *DockerNetwork) Remove(ctx context.Context) error {
select {
// close reaper if it was created
case n.terminationSignal <- true:
default:
}
return n.provider.client.NetworkRemove(ctx, n.ID)
}

Expand Down

0 comments on commit b5754a6

Please sign in to comment.