mirror of
https://github.com/containers/podman.git
synced 2025-10-17 03:04:21 +08:00
Merge pull request #26945 from Luap99/vol-opts
do not pass volume options as bind mounts options to runtime
This commit is contained in:
@ -504,6 +504,15 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
||||
_, err := r.state.Volume(vol.Name)
|
||||
if err == nil {
|
||||
// The volume exists, we're good
|
||||
// Make sure to drop all volume-opt options as they only apply to
|
||||
// the volume create which we don't do again.
|
||||
var volOpts []string
|
||||
for _, opts := range vol.Options {
|
||||
if !strings.HasPrefix(opts, "volume-opt") {
|
||||
volOpts = append(volOpts, opts)
|
||||
}
|
||||
}
|
||||
vol.Options = volOpts
|
||||
continue
|
||||
} else if !errors.Is(err, define.ErrNoSuchVolume) {
|
||||
return nil, fmt.Errorf("retrieving named volume %s for new container: %w", vol.Name, err)
|
||||
@ -530,6 +539,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
||||
if len(vol.Options) > 0 {
|
||||
isDriverOpts := false
|
||||
driverOpts := make(map[string]string)
|
||||
var volOpts []string
|
||||
for _, opts := range vol.Options {
|
||||
if strings.HasPrefix(opts, "volume-opt") {
|
||||
isDriverOpts = true
|
||||
@ -538,8 +548,11 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
||||
return nil, err
|
||||
}
|
||||
driverOpts[driverOptKey] = driverOptValue
|
||||
} else {
|
||||
volOpts = append(volOpts, opts)
|
||||
}
|
||||
}
|
||||
vol.Options = volOpts
|
||||
if isDriverOpts {
|
||||
parsedOptions := []VolumeCreateOption{WithVolumeOptions(driverOpts)}
|
||||
volOptions = append(volOptions, parsedOptions...)
|
||||
|
Reference in New Issue
Block a user