fix(ctr): enable networking for Windows containers

Signed-off-by: Markus Lippert <lippertmarkus@gmx.de>
This commit is contained in:
Markus Lippert
2021-12-21 07:13:39 +01:00
parent 591d7097e7
commit f39b3ac7ea
4 changed files with 47 additions and 5 deletions

View File

@@ -123,6 +123,10 @@ var Command = cli.Command{
Name: "platform",
Usage: "run image for specific platform",
},
cli.BoolFlag{
Name: "cni",
Usage: "enable cni networking for the container",
},
}, append(platformRunFlags,
append(append(commands.SnapshotterFlags, []cli.Flag{commands.SnapshotterLabels}...),
commands.ContainerFlags...)...)...),
@@ -209,7 +213,12 @@ var Command = cli.Command{
}
}
if enableCNI {
if _, err := network.Setup(ctx, fullID(ctx, container), fmt.Sprintf("/proc/%d/ns/net", task.Pid())); err != nil {
netNsPath, err := getNetNSPath(ctx, task)
if err != nil {
return err
}
if _, err := network.Setup(ctx, fullID(ctx, container), netNsPath); err != nil {
return err
}
}