Support parallel kill

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
Zhang Wei 2016-09-21 22:06:43 +08:00
parent b7722cd80a
commit f612b93d33
1 changed files with 4 additions and 1 deletions

View File

@ -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)