mirror of https://github.com/docker/cli.git
Support parallel kill
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
parent
b7722cd80a
commit
f612b93d33
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue