Merge pull request #8413 from dcantah/sb_ctr_run

ctr: Add sandbox flag to ctr run
This commit is contained in:
Fu Wei 2023-04-20 13:25:40 +08:00 committed by GitHub
commit fdd1be6734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 0 deletions

View File

@ -141,6 +141,10 @@ var (
Usage: "Runtime name or absolute path to runtime binary",
Value: defaults.DefaultRuntime,
},
cli.StringFlag{
Name: "sandbox",
Usage: "Create the container in the given sandbox",
},
cli.StringFlag{
Name: "runtime-config-path",
Usage: "Optional runtime config path",

View File

@ -164,6 +164,7 @@ var Command = cli.Command{
return err
}
defer cancel()
container, err := NewContainer(ctx, client, context)
if err != nil {
return err

View File

@ -102,6 +102,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
spec containerd.NewContainerOpts
)
if sandbox := context.String("sandbox"); sandbox != "" {
cOpts = append(cOpts, containerd.WithSandbox(sandbox))
}
if config {
cOpts = append(cOpts, containerd.WithContainerLabels(commands.LabelArgs(context.StringSlice("label"))))
opts = append(opts, oci.WithSpecFromFile(context.String("config")))

View File

@ -51,6 +51,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
config = context.IsSet("config")
)
if sandbox := context.String("sandbox"); sandbox != "" {
cOpts = append(cOpts, containerd.WithSandbox(sandbox))
}
if config {
id = context.Args().First()
opts = append(opts, oci.WithSpecFromFile(context.String("config")))