Add --device flag to ctr

Closes #3066

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2019-07-17 20:35:00 +00:00
parent dca17853d8
commit 725d3ad8cb
6 changed files with 179 additions and 0 deletions

View File

@@ -126,6 +126,10 @@ var (
Name: "memory-limit",
Usage: "memory limit (in bytes) for the container",
},
cli.StringSliceFlag{
Name: "device",
Usage: "add a device to a container",
},
}
// ImageDecryptionFlags are cli flags needed when decrypting an image
ImageDecryptionFlags = []cli.Flag{

View File

@@ -155,6 +155,9 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
if limit != 0 {
opts = append(opts, oci.WithMemoryLimit(limit))
}
for _, dev := range context.StringSlice("device") {
opts = append(opts, oci.WithLinuxDevice(dev, "rwm"))
}
}
cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), nil))