diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-04 13:46:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-04 13:46:56 -0500 |
commit | e65bcc166c3bc7e039ff0909c2cac919ce0122ad (patch) | |
tree | 8cab909fa688ac16ef73c5f19869a1cad468fba6 /cmd | |
parent | 7a92de4bacdff145a871371d5a306bd349e83374 (diff) | |
parent | 53d22c779c5d2df5ccda5a8e23db0501a0dadf44 (diff) | |
download | podman-e65bcc166c3bc7e039ff0909c2cac919ce0122ad.tar.gz podman-e65bcc166c3bc7e039ff0909c2cac919ce0122ad.tar.bz2 podman-e65bcc166c3bc7e039ff0909c2cac919ce0122ad.zip |
Merge pull request #9604 from mheon/fix_9510
Compat API: create volume source dirs on the host
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/common/create_opts.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index f945c9c54..03cd8a721 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -3,6 +3,7 @@ package common import ( "fmt" "net" + "os" "path/filepath" "strconv" "strings" @@ -13,6 +14,7 @@ import ( "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/specgen" + "github.com/pkg/errors" ) type ContainerCLIOpts struct { @@ -397,6 +399,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup } // volumes + volSources := make(map[string]bool) volDestinations := make(map[string]bool) for _, vol := range cc.HostConfig.Binds { cliOpts.Volume = append(cliOpts.Volume, vol) @@ -407,6 +410,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup case 1: volDestinations[vol] = true default: + volSources[splitVol[0]] = true volDestinations[splitVol[1]] = true } } @@ -421,6 +425,19 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup } cliOpts.Volume = append(cliOpts.Volume, vol) } + // Make mount points for compat volumes + for vol := range volSources { + // This might be a named volume. + // Assume it is if it's not an absolute path. + if !filepath.IsAbs(vol) { + continue + } + if err := os.MkdirAll(vol, 0755); err != nil { + if !os.IsExist(err) { + return nil, nil, errors.Wrapf(err, "error making volume mountpoint for volume %s", vol) + } + } + } if len(cc.HostConfig.BlkioWeightDevice) > 0 { devices := make([]string, 0, len(cc.HostConfig.BlkioWeightDevice)) for _, d := range cc.HostConfig.BlkioWeightDevice { |