mirror of
https://github.com/containers/podman.git
synced 2025-07-31 12:22:29 +08:00
Merge pull request #5222 from mheon/fix_5219
Use cleaned destination path for indexing image volumes
This commit is contained in:
@ -739,6 +739,7 @@ func (config *CreateConfig) getImageVolumes() (map[string]spec.Mount, map[string
|
|||||||
|
|
||||||
for vol := range config.BuiltinImgVolumes {
|
for vol := range config.BuiltinImgVolumes {
|
||||||
cleanDest := filepath.Clean(vol)
|
cleanDest := filepath.Clean(vol)
|
||||||
|
logrus.Debugf("Adding image volume at %s", cleanDest)
|
||||||
if config.ImageVolumeType == "tmpfs" {
|
if config.ImageVolumeType == "tmpfs" {
|
||||||
// Tmpfs image volumes are handled as mounts
|
// Tmpfs image volumes are handled as mounts
|
||||||
mount := spec.Mount{
|
mount := spec.Mount{
|
||||||
@ -747,13 +748,13 @@ func (config *CreateConfig) getImageVolumes() (map[string]spec.Mount, map[string
|
|||||||
Type: TypeTmpfs,
|
Type: TypeTmpfs,
|
||||||
Options: []string{"rprivate", "rw", "nodev", "exec"},
|
Options: []string{"rprivate", "rw", "nodev", "exec"},
|
||||||
}
|
}
|
||||||
mounts[vol] = mount
|
mounts[cleanDest] = mount
|
||||||
} else {
|
} else {
|
||||||
// Anonymous volumes have no name.
|
// Anonymous volumes have no name.
|
||||||
namedVolume := new(libpod.ContainerNamedVolume)
|
namedVolume := new(libpod.ContainerNamedVolume)
|
||||||
namedVolume.Options = []string{"rprivate", "rw", "nodev", "exec"}
|
namedVolume.Options = []string{"rprivate", "rw", "nodev", "exec"}
|
||||||
namedVolume.Dest = cleanDest
|
namedVolume.Dest = cleanDest
|
||||||
volumes[vol] = namedVolume
|
volumes[cleanDest] = namedVolume
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,10 @@ import (
|
|||||||
"github.com/onsi/gomega/gexec"
|
"github.com/onsi/gomega/gexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var VolumeTrailingSlashDockerfile = `
|
||||||
|
FROM alpine:latest
|
||||||
|
VOLUME /test/`
|
||||||
|
|
||||||
var _ = Describe("Podman run with volumes", func() {
|
var _ = Describe("Podman run with volumes", func() {
|
||||||
var (
|
var (
|
||||||
tempdir string
|
tempdir string
|
||||||
@ -421,4 +425,20 @@ var _ = Describe("Podman run with volumes", func() {
|
|||||||
Expect(len(outputArr)).To(Equal(1))
|
Expect(len(outputArr)).To(Equal(1))
|
||||||
Expect(strings.Contains(outputArr[0], fileName)).To(BeTrue())
|
Expect(strings.Contains(outputArr[0], fileName)).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("Podman mount over image volume with trailing /", func() {
|
||||||
|
image := "podman-volume-test:trailing"
|
||||||
|
podmanTest.BuildImage(VolumeTrailingSlashDockerfile, image, "false")
|
||||||
|
|
||||||
|
ctrName := "testCtr"
|
||||||
|
create := podmanTest.Podman([]string{"create", "-v", "/tmp:/test", "--name", ctrName, image, "ls"})
|
||||||
|
create.WaitWithDefaultTimeout()
|
||||||
|
Expect(create.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
data := podmanTest.InspectContainer(ctrName)
|
||||||
|
Expect(len(data)).To(Equal(1))
|
||||||
|
Expect(len(data[0].Mounts)).To(Equal(1))
|
||||||
|
Expect(data[0].Mounts[0].Source).To(Equal("/tmp"))
|
||||||
|
Expect(data[0].Mounts[0].Destination).To(Equal("/test"))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user