ctr: allow specifying --runc-binary
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
c038a7c4b1
commit
7f5d900769
@ -29,12 +29,18 @@ import (
|
||||
"github.com/containerd/containerd/contrib/seccomp"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/containerd/containerd/runtime/v2/runc/options"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var platformRunFlags []cli.Flag
|
||||
var platformRunFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "runc-binary",
|
||||
Usage: "specify runc-compatible binary",
|
||||
},
|
||||
}
|
||||
|
||||
// NewContainer creates a new container
|
||||
func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli.Context) (containerd.Container, error) {
|
||||
@ -167,7 +173,15 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
}
|
||||
}
|
||||
|
||||
cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), nil))
|
||||
runtimeOpts := &options.Options{}
|
||||
if runcBinary := context.String("runc-binary"); runcBinary != "" {
|
||||
if context.String("runtime") == "io.containerd.runc.v2" {
|
||||
runtimeOpts.BinaryName = runcBinary
|
||||
} else {
|
||||
return nil, errors.New("specifying runc-binary is only supported for \"io.containerd.runc.v2\" runtime")
|
||||
}
|
||||
}
|
||||
cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), runtimeOpts))
|
||||
|
||||
opts = append(opts, oci.WithAnnotations(commands.LabelArgs(context.StringSlice("label"))))
|
||||
var s specs.Spec
|
||||
|
Loading…
Reference in New Issue
Block a user