diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-09-06 13:55:12 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-09-07 17:50:58 +0000 |
commit | 2e89e5a204dd99a2bfff25c97fa2f4583c0a3ae1 (patch) | |
tree | a1125749273aca95e15a079bd772dda78022589f /pkg | |
parent | 6f2bd8d79565c0ddfb830c68a144d8cd2e7f350b (diff) | |
download | podman-2e89e5a204dd99a2bfff25c97fa2f4583c0a3ae1.tar.gz podman-2e89e5a204dd99a2bfff25c97fa2f4583c0a3ae1.tar.bz2 podman-2e89e5a204dd99a2bfff25c97fa2f4583c0a3ae1.zip |
Ensure we do not overlap mounts in the spec
When user-specified volume mounts overlap with mounts already in
the spec, remove the mount in the spec to ensure there are no
conflicts.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #1419
Approved by: TomSweeneyRedHat
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/spec/spec.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index 11bc880cb..12b3b42b5 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -305,11 +305,24 @@ func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint if err := config.GetVolumesFrom(); err != nil { return nil, errors.Wrap(err, "error getting volume mounts from --volumes-from flag") } + mounts, err := config.GetVolumeMounts(configSpec.Mounts) if err != nil { return nil, errors.Wrapf(err, "error getting volume mounts") } - configSpec.Mounts = append(configSpec.Mounts, mounts...) + // If we have overlappings mounts, remove them from the spec in favor of + // the user-added volume mounts + destinations := make(map[string]bool) + for _, mount := range mounts { + destinations[mount.Destination] = true + } + for _, mount := range configSpec.Mounts { + if _, ok := destinations[mount.Destination]; !ok { + mounts = append(mounts, mount) + } + } + configSpec.Mounts = mounts + if err := g.SetLinuxRootPropagation("shared"); err != nil { return nil, errors.Wrapf(err, "failed to set propagation to rslave") } |