Skip to content

Commit

Permalink
don't error on deleting old build containers without state volume
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Jul 16, 2021
1 parent 65a6955 commit 0b6ba1c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions driver/docker-container/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,24 @@ func (d *Driver) Rm(ctx context.Context, force bool, rmVolume bool) error {
return err
}
if info.Status != driver.Inactive {
container, err := d.DockerAPI.ContainerInspect(ctx, d.Name)
if err != nil {
return err
}
if err := d.DockerAPI.ContainerRemove(ctx, d.Name, dockertypes.ContainerRemoveOptions{
RemoveVolumes: true,
Force: force,
}); err != nil {
return err
}
if rmVolume {
return d.DockerAPI.VolumeRemove(ctx, d.Name+volumeStateSuffix, false)
for _, v := range container.Mounts {
if v.Name == d.Name+volumeStateSuffix {
if rmVolume {
return d.DockerAPI.VolumeRemove(ctx, d.Name+volumeStateSuffix, false)
}
}
}

}
return nil
}
Expand Down

0 comments on commit 0b6ba1c

Please sign in to comment.