mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
Merge pull request #10220 from giuseppe/rm-volatile
podman: set volatile storage flag for --rm containers
This commit is contained in:
@@ -151,6 +151,9 @@ type ContainerRootFSConfig struct {
|
||||
Secrets []*secrets.Secret `json:"secrets,omitempty"`
|
||||
// SecretPath is the secrets location in storage
|
||||
SecretsPath string `json:"secretsPath"`
|
||||
// Volatile specifies whether the container storage can be optimized
|
||||
// at the cost of not syncing all the dirty files in memory.
|
||||
Volatile bool `json:"volatile,omitempty"`
|
||||
}
|
||||
|
||||
// ContainerSecurityConfig is an embedded sub-config providing security configuration
|
||||
|
||||
@@ -451,6 +451,8 @@ func (c *Container) setupStorage(ctx context.Context) error {
|
||||
options.MountOpts = newOptions
|
||||
}
|
||||
|
||||
options.Volatile = c.config.Volatile
|
||||
|
||||
c.setupStorageMapping(&options.IDMappingOptions, &c.config.IDMappings)
|
||||
|
||||
containerInfo, err := c.runtime.storageService.CreateContainerStorage(ctx, c.runtime.imageContext, c.config.RootfsImageName, c.config.RootfsImageID, c.config.Name, c.config.ID, options)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user