chore: remove anonymous volumes for ucind containers

This commit is contained in:
Pavel Sviderski
2025-04-03 16:35:48 +10:00
parent 9fc54c9d64
commit 4e40a93991
+6 -1
View File
@@ -279,7 +279,12 @@ func (p *Provisioner) RemoveCluster(ctx context.Context, name string) error {
return fmt.Errorf("list Docker containers with cluster name '%s': %w", name, err) return fmt.Errorf("list Docker containers with cluster name '%s': %w", name, err)
} }
for _, c := range containers { for _, c := range containers {
if err = p.dockerCli.ContainerRemove(ctx, c.ID, container.RemoveOptions{Force: true}); err != nil { removeOpts := container.RemoveOptions{
// Remove anonymous volumes attached to the container (typically /var/lib/docker).
RemoveVolumes: true,
Force: true,
}
if err = p.dockerCli.ContainerRemove(ctx, c.ID, removeOpts); err != nil {
return fmt.Errorf("remove Docker container '%s': %w", c.ID, err) return fmt.Errorf("remove Docker container '%s': %w", c.ID, err)
} }
} }