mirror of
https://github.com/containers/podman.git
synced 2025-12-08 23:00:23 +08:00
podman run/create -v relative filepath support
podman currently does not support relative volume paths. Add parsing for relative paths in specgen, converting whatever volume was given to an absolute path. Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
@@ -953,4 +953,32 @@ USER testuser`, fedoraMinimal)
|
||||
Expect(volMount).Should(Exit(0))
|
||||
Expect(volMount.OutputToString()).To(Equal("1000:1000"))
|
||||
})
|
||||
|
||||
It("podman run -v with a relative dir", func() {
|
||||
mountPath := filepath.Join(podmanTest.TempDir, "vol")
|
||||
err = os.Mkdir(mountPath, 0755)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer func() {
|
||||
err := os.RemoveAll(mountPath)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}()
|
||||
|
||||
f, err := os.CreateTemp(mountPath, "podman")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
err = os.Chdir(mountPath)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer func() {
|
||||
err := os.Chdir(cwd)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}()
|
||||
|
||||
run := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=disable", "-v", "./:" + dest, ALPINE, "ls", dest})
|
||||
run.WaitWithDefaultTimeout()
|
||||
Expect(run).Should(Exit(0))
|
||||
Expect(run.OutputToString()).Should(ContainSubstring(strings.TrimLeft("/vol/", f.Name())))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user