Skip to content

Commit 5d9b937

Browse files
committed
feat: Support oci other than runsc
1 parent ea37068 commit 5d9b937

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

sandbox/sandbox.go

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -445,18 +445,34 @@ func startContainer(ctx context.Context) (c *Container, err error) {
445445

446446
name := "play_run_" + randHex(8)
447447
setContainerWanted(name, true)
448-
cmd := exec.Command("docker", "run",
449-
"--name="+name,
450-
"--rm",
451-
"--tmpfs=/tmpfs:exec",
452-
"-i", // read stdin
453-
454-
"--runtime=runsc",
455-
"--network=none",
456-
"--memory="+fmt.Sprint(memoryLimitBytes),
457-
458-
*container,
459-
"--mode=contained")
448+
var cmd *exec.Cmd
449+
if _, err := os.Stat("/var/lib/docker/runsc"); err == nil {
450+
cmd = exec.Command("docker", "run",
451+
"--name="+name,
452+
"--rm",
453+
"--tmpfs=/tmpfs:exec",
454+
"-i", // read stdin
455+
456+
"--runtime=runsc",
457+
"--network=none",
458+
"--memory="+fmt.Sprint(memoryLimitBytes),
459+
460+
*container,
461+
"--mode=contained")
462+
} else {
463+
cmd = exec.Command("docker", "run",
464+
"--name="+name,
465+
"--rm",
466+
"--tmpfs=/tmpfs:exec",
467+
"-i", // read stdin
468+
469+
"--network=none",
470+
"--memory="+fmt.Sprint(memoryLimitBytes),
471+
472+
*container,
473+
"--mode=contained")
474+
}
475+
460476
stdin, err := cmd.StdinPipe()
461477
if err != nil {
462478
return nil, err

0 commit comments

Comments
 (0)