fix trying to pause multiple containers with runc

pull/13783/head
Steven Powell 2022-03-14 12:00:13 -07:00
parent 45f5e4c2d3
commit a90565f0ce
1 changed files with 5 additions and 4 deletions

View File

@ -140,13 +140,14 @@ func listCRIContainers(cr CommandRunner, root string, o ListContainersOptions) (
// pauseContainers pauses a list of containers
func pauseCRIContainers(cr CommandRunner, root string, ids []string) error {
args := []string{"runc"}
baseArgs := []string{"runc"}
if root != "" {
args = append(args, "--root", root)
baseArgs = append(baseArgs, "--root", root)
}
args = append(args, "pause")
baseArgs = append(baseArgs, "pause")
for _, id := range ids {
args := append(args, id)
args := baseArgs
args = append(args, id)
if _, err := cr.RunCmd(exec.Command("sudo", args...)); err != nil {
return errors.Wrap(err, "runc")
}