Skip to content

Commit 46d7575

Browse files
committed
do not pass [no]copy as bind mounts options to runtime
Starting with runc 1.3.0 it errors when we pass unknown mount options to the runtime, the copy/nocopy options are specific to podman when we mount the volume and are not valid mount options for the runtime. Fixes: #26938 Signed-off-by: Paul Holzinger <[email protected]>
1 parent 4e2a04d commit 46d7575

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

libpod/container_internal_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
420420
// Podman decided for --no-dereference as many
421421
// bin-utils tools (e..g, touch, chown, cp) do.
422422
options = append(options, "copy-symlink")
423+
case "copy", "nocopy":
424+
// no real OCI runtime bind mount options, these should already be handled by the named volume mount above
423425
default:
424426
options = append(options, o)
425427
}

test/e2e/run_volume_test.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package integration
44

55
import (
6+
"encoding/json"
67
"fmt"
78
"os"
89
"os/exec"
@@ -15,6 +16,7 @@ import (
1516
. "github.com/onsi/ginkgo/v2"
1617
. "github.com/onsi/gomega"
1718
. "github.com/onsi/gomega/gexec"
19+
"github.com/opencontainers/runtime-spec/specs-go"
1820
)
1921

2022
// in-container mount point: using a path that is definitely not present
@@ -448,9 +450,27 @@ var _ = Describe("Podman run with volumes", func() {
448450
Expect(separateVolumeSession).Should(ExitCleanly())
449451
Expect(separateVolumeSession.OutputToString()).To(Equal(baselineOutput))
450452

451-
copySession := podmanTest.Podman([]string{"run", "--rm", "-v", "testvol3:/etc/apk:copy", ALPINE, "stat", "-c", "%h", "/etc/apk/arch"})
452-
copySession.WaitWithDefaultTimeout()
453-
Expect(copySession).Should(ExitCleanly())
453+
podmanTest.PodmanExitCleanly("run", "--name", "testctr", "-v", "testvol3:/etc/apk:copy", ALPINE, "stat", "-c", "%h", "/etc/apk/arch")
454+
455+
inspect := podmanTest.PodmanExitCleanly("container", "inspect", "testctr", "--format", "{{.OCIConfigPath}}")
456+
457+
// Make extra check that the OCI config does not contain the copy opt, runc 1.3.0 fails on that while crun does not.
458+
// We only test crun upstream so make sure the spec is sane: https://github.com/containers/podman/issues/26938
459+
f, err := os.Open(inspect.OutputToString())
460+
Expect(err).ToNot(HaveOccurred())
461+
defer f.Close()
462+
var spec specs.Spec
463+
err = json.NewDecoder(f).Decode(&spec)
464+
Expect(err).ToNot(HaveOccurred())
465+
466+
found := false
467+
for _, m := range spec.Mounts {
468+
if m.Destination == "/etc/apk" {
469+
found = true
470+
Expect(m.Options).To(Equal([]string{"rprivate", "nosuid", "nodev", "rbind"}))
471+
}
472+
}
473+
Expect(found).To(BeTrue(), "OCI spec contains /etc/apk mount")
454474

455475
noCopySession := podmanTest.Podman([]string{"run", "--rm", "-v", "testvol4:/etc/apk:nocopy", ALPINE, "stat", "-c", "%h", "/etc/apk/arch"})
456476
noCopySession.WaitWithDefaultTimeout()

0 commit comments

Comments
 (0)