mirror of
https://github.com/containers/podman.git
synced 2025-05-22 01:27:07 +08:00
Remove a volume with --force if container is running
Currently we are not passing the force flag down to the removal of the running container. If the container is running, and we set --force when removing the volume, the container should be stopped. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -230,11 +230,7 @@ func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force bool, timeo
|
|||||||
|
|
||||||
logrus.Debugf("Removing container %s (depends on volume %q)", ctr.ID(), v.Name())
|
logrus.Debugf("Removing container %s (depends on volume %q)", ctr.ID(), v.Name())
|
||||||
|
|
||||||
// TODO: do we want to set force here when removing
|
if err := r.removeContainer(ctx, ctr, force, false, false, timeout); err != nil {
|
||||||
// containers?
|
|
||||||
// I'm inclined to say no, in case someone accidentally
|
|
||||||
// wipes a container they're using...
|
|
||||||
if err := r.removeContainer(ctx, ctr, false, false, false, timeout); err != nil {
|
|
||||||
return errors.Wrapf(err, "error removing container %s that depends on volume %s", ctr.ID(), v.Name())
|
return errors.Wrapf(err, "error removing container %s that depends on volume %s", ctr.ID(), v.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,14 @@ Labels.l | $mylabel
|
|||||||
run_podman volume rm $myvolume
|
run_podman volume rm $myvolume
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Removing volumes with --force
|
||||||
|
@test "podman volume rm --force" {
|
||||||
|
run_podman run -d --volume myvol:/myvol $IMAGE top
|
||||||
|
cid=$output
|
||||||
|
run_podman 2 volume rm myvol
|
||||||
|
is "$output" "Error: volume myvol is being used by the following container(s): $cid: volume is being used" "should error since container is running"
|
||||||
|
run_podman volume rm myvol --force
|
||||||
|
}
|
||||||
|
|
||||||
# Running scripts (executables) from a volume
|
# Running scripts (executables) from a volume
|
||||||
@test "podman volume: exec/noexec" {
|
@test "podman volume: exec/noexec" {
|
||||||
|
Reference in New Issue
Block a user