Skip to content

Commit

Permalink
Fix the --runtime option of container create is ignored
Browse files Browse the repository at this point in the history
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
  • Loading branch information
yankay committed Aug 7, 2023
1 parent 9cd00de commit 5218242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/nerdctl/compose_up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ services:
c := base.ComposeCmd("-f", comp.YAMLFullPath(), "up", "-d")
expected := icmd.Expected{
ExitCode: 1,
Err: `exec: \"invalid\": executable file not found in $PATH`,
Err: `failed to resolve runtime path: invalid runtime name invalid`,
}
if base.Target == testutil.Docker {
expected.Err = `Unknown runtime specified invalid`
expected.Err = `unknown or invalid runtime name: invalid`
}
c.Assert(expected)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/container/run_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package container

import (
"context"
"path/filepath"
"strings"

"github.com/containerd/containerd"
Expand All @@ -39,6 +40,7 @@ func generateRuntimeCOpts(cgroupManager, runtimeStr string) ([]containerd.NewCon
runcOpts.SystemdCgroup = true
}
if runtimeStr != "" {

if strings.HasPrefix(runtimeStr, "io.containerd.") || runtimeStr == "wtf.sbk.runj.v1" {
runtime = runtimeStr
if !strings.HasPrefix(runtimeStr, "io.containerd.runc.") {
Expand All @@ -47,8 +49,9 @@ func generateRuntimeCOpts(cgroupManager, runtimeStr string) ([]containerd.NewCon
}
runtimeOpts = nil
}
} else {
} else if filepath.IsAbs(runtimeStr) {
// runtimeStr is a runc binary
runtime = runtimeStr
runcOpts.BinaryName = runtimeStr
}
}
Expand Down

0 comments on commit 5218242

Please sign in to comment.