From f612b93d336fc9430d6780a84ad2667ebd61d0ef Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Wed, 21 Sep 2016 22:06:43 +0800 Subject: [PATCH] Support parallel kill Signed-off-by: Zhang Wei --- command/container/kill.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/command/container/kill.go b/command/container/kill.go index 8d9af6f7a6..6da91a40e3 100644 --- a/command/container/kill.go +++ b/command/container/kill.go @@ -39,8 +39,11 @@ func NewKillCommand(dockerCli *command.DockerCli) *cobra.Command { func runKill(dockerCli *command.DockerCli, opts *killOptions) error { var errs []string ctx := context.Background() + errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error { + return dockerCli.Client().ContainerKill(ctx, container, opts.signal) + }) for _, name := range opts.containers { - if err := dockerCli.Client().ContainerKill(ctx, name, opts.signal); err != nil { + if err := <-errChan; err != nil { errs = append(errs, err.Error()) } else { fmt.Fprintf(dockerCli.Out(), "%s\n", name)