Merge pull request #7082 from samuelkarp/ctr-hostname

ctr: add --hostname flag to create, run
This commit is contained in:
Akihiro Suda 2022-06-20 19:35:15 -05:00 committed by GitHub
commit b56cac143a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -201,6 +201,10 @@ var (
Name: "rdt-class", Name: "rdt-class",
Usage: "name of the RDT class to associate the container with. Specifies a Class of Service (CLOS) for cache and memory bandwidth management.", Usage: "name of the RDT class to associate the container with. Specifies a Class of Service (CLOS) for cache and memory bandwidth management.",
}, },
cli.StringFlag{
Name: "hostname",
Usage: "set the container's host name",
},
} }
) )

View File

@ -106,7 +106,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
} else { } else {
var ( var (
ref = context.Args().First() ref = context.Args().First()
//for container's id is Args[1] // for container's id is Args[1]
args = context.Args()[2:] args = context.Args()[2:]
) )
opts = append(opts, oci.WithDefaultSpec(), oci.WithDefaultUnixDevices) opts = append(opts, oci.WithDefaultSpec(), oci.WithDefaultUnixDevices)
@ -346,6 +346,9 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
if c := context.String("rdt-class"); c != "" { if c := context.String("rdt-class"); c != "" {
opts = append(opts, oci.WithRdt(c, "", "")) opts = append(opts, oci.WithRdt(c, "", ""))
} }
if hostname := context.String("hostname"); hostname != "" {
opts = append(opts, oci.WithHostname(hostname))
}
} }
runtimeOpts, err := getRuntimeOptions(context) runtimeOpts, err := getRuntimeOptions(context)