mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
Merge pull request #676 from tonistiigi/vol-delete
don't error on deleting old build containers without state volume
This commit is contained in:
commit
d9ee3b134c
@ -275,15 +275,24 @@ func (d *Driver) Rm(ctx context.Context, force bool, rmVolume bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if info.Status != driver.Inactive {
|
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{
|
if err := d.DockerAPI.ContainerRemove(ctx, d.Name, dockertypes.ContainerRemoveOptions{
|
||||||
RemoveVolumes: true,
|
RemoveVolumes: true,
|
||||||
Force: force,
|
Force: force,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if rmVolume {
|
for _, v := range container.Mounts {
|
||||||
return d.DockerAPI.VolumeRemove(ctx, d.Name+volumeStateSuffix, false)
|
if v.Name == d.Name+volumeStateSuffix {
|
||||||
|
if rmVolume {
|
||||||
|
return d.DockerAPI.VolumeRemove(ctx, d.Name+volumeStateSuffix, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user