From 83db80ce172975ddb7c5bfc0d1cea03d5c6b6c94 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 26 Feb 2019 12:16:58 -0500 Subject: Only remove image volumes when removing containers When removing volumes with rm --volumes we want to only remove volumes that were created with the container. Volumes created separately via 'podman volume create' should not be removed. Also ensure that --rm implies volumes will be removed. Fixes #2441 Signed-off-by: Matthew Heon --- libpod/options.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libpod/options.go') diff --git a/libpod/options.go b/libpod/options.go index 184d5d59f..1e8592a25 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1248,6 +1248,22 @@ func WithVolumeOptions(options map[string]string) VolumeCreateOption { } } +// withSetCtrSpecific sets a bool notifying libpod that a volume was created +// specifically for a container. +// These volumes will be removed when the container is removed and volumes are +// also specified for removal. +func withSetCtrSpecific() VolumeCreateOption { + return func(volume *Volume) error { + if volume.valid { + return ErrVolumeFinalized + } + + volume.config.IsCtrSpecific = true + + return nil + } +} + // Pod Creation Options // WithPodName sets the name of the pod. -- cgit v1.2.3-54-g00ecf