From 68fe1950fe5bad7e29b7a75bb1e94a54fd7e5360 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 5 May 2021 15:44:29 +0200 Subject: podman: set volatile storage flag for --rm containers volatile containers are a storage optimization that disables *sync() syscalls for the container rootfs. If a container is created with --rm, then automatically set the volatile storage flag as anyway the container won't persist after a reboot or machine crash. [NO TESTS NEEDED] Signed-off-by: Giuseppe Scrivano --- libpod/options.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libpod/options.go') diff --git a/libpod/options.go b/libpod/options.go index 39415a817..391cf0147 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -2318,3 +2318,16 @@ func WithPodSlirp4netns(networkOptions map[string][]string) PodCreateOption { return nil } } + +// WithVolatile sets the volatile flag for the container storage. +// The option can potentially cause data loss when used on a container that must survive a machine reboot. +func WithVolatile() CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return define.ErrCtrFinalized + } + + ctr.config.Volatile = true + return nil + } +} -- cgit v1.2.3-54-g00ecf