Skip to content

Commit a038f2d

Browse files
authored
Merge pull request containerd#1894 from thaJeztah/refactor_withBindMountHostIPC
cmd/nerdctl: withBindMountHostIPC: slight refactor
2 parents b91a717 + 0088e84 commit a038f2d

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

cmd/nerdctl/run.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -901,23 +901,14 @@ func generateRootfsOpts(ctx context.Context, client *containerd.Client, platform
901901
// Required for --ipc=host on rootless.
902902
func withBindMountHostIPC(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
903903
for i, m := range s.Mounts {
904-
if path.Clean(m.Destination) == "/dev/shm" {
905-
newM := specs.Mount{
906-
Destination: "/dev/shm",
904+
switch p := path.Clean(m.Destination); p {
905+
case "/dev/shm", "/dev/mqueue":
906+
s.Mounts[i] = specs.Mount{
907+
Destination: p,
907908
Type: "bind",
908-
Source: "/dev/shm",
909+
Source: p,
909910
Options: []string{"rbind", "nosuid", "noexec", "nodev"},
910911
}
911-
s.Mounts[i] = newM
912-
}
913-
if path.Clean(m.Destination) == "/dev/mqueue" {
914-
newM := specs.Mount{
915-
Destination: "/dev/mqueue",
916-
Type: "bind",
917-
Source: "/dev/mqueue",
918-
Options: []string{"rbind", "nosuid", "noexec", "nodev"},
919-
}
920-
s.Mounts[i] = newM
921912
}
922913
}
923914
return nil

0 commit comments

Comments
 (0)