summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-27 12:50:11 +0100
committerGitHub <noreply@github.com>2021-01-27 12:50:11 +0100
commit179b9d1745db19cb420b0a8f8d6afa4dfc07dd91 (patch)
tree8acc8eaf177c93d74e6b7ed243197ff01c995078 /cmd/podman
parent5c6175df390031bcf34d28935a79ee467cca7e7d (diff)
parent1ae410d19e0ead7db89192b3d0e290a677314d6e (diff)
downloadpodman-179b9d1745db19cb420b0a8f8d6afa4dfc07dd91.tar.gz
podman-179b9d1745db19cb420b0a8f8d6afa4dfc07dd91.tar.bz2
podman-179b9d1745db19cb420b0a8f8d6afa4dfc07dd91.zip
Merge pull request #9025 from mheon/add_support_volumes_field
Ensure the Volumes field in Compat Create is honored
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create_opts.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index a4da8da9e..d86a6d364 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -3,6 +3,7 @@ package common
import (
"fmt"
"net"
+ "path/filepath"
"strconv"
"strings"
@@ -383,8 +384,29 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
}
// volumes
- if volumes := cc.HostConfig.Binds; len(volumes) > 0 {
- cliOpts.Volume = volumes
+ volDestinations := make(map[string]bool)
+ for _, vol := range cc.HostConfig.Binds {
+ cliOpts.Volume = append(cliOpts.Volume, vol)
+ // Extract the destination so we don't add duplicate mounts in
+ // the volumes phase.
+ splitVol := strings.SplitN(vol, ":", 3)
+ switch len(splitVol) {
+ case 1:
+ volDestinations[vol] = true
+ default:
+ volDestinations[splitVol[1]] = true
+ }
+ }
+ // Anonymous volumes are added differently from other volumes, in their
+ // own special field, for reasons known only to Docker. Still use the
+ // format of `-v` so we can just append them in there.
+ // Unfortunately, these may be duplicates of existing mounts in Binds.
+ // So... We need to catch that.
+ for vol := range cc.Volumes {
+ if _, ok := volDestinations[filepath.Clean(vol)]; ok {
+ continue
+ }
+ cliOpts.Volume = append(cliOpts.Volume, vol)
}
if len(cc.HostConfig.BlkioWeightDevice) > 0 {
devices := make([]string, 0, len(cc.HostConfig.BlkioWeightDevice))