github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/api/client/kill.go (about) 1 package client 2 3 import ( 4 "fmt" 5 "strings" 6 7 Cli "github.com/docker/docker/cli" 8 flag "github.com/docker/docker/pkg/mflag" 9 ) 10 11 // CmdKill kills one or more running container using SIGKILL or a specified signal. 12 // 13 // Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] 14 func (cli *DockerCli) CmdKill(args ...string) error { 15 cmd := Cli.Subcmd("kill", []string{"CONTAINER [CONTAINER...]"}, Cli.DockerCommands["kill"].Description, true) 16 signal := cmd.String([]string{"s", "-signal"}, "KILL", "Signal to send to the container") 17 cmd.Require(flag.Min, 1) 18 19 cmd.ParseFlags(args, true) 20 21 var errs []string 22 for _, name := range cmd.Args() { 23 if err := cli.client.ContainerKill(name, *signal); err != nil { 24 errs = append(errs, fmt.Sprintf("Failed to kill container (%s): %s", name, err)) 25 } else { 26 fmt.Fprintf(cli.out, "%s\n", name) 27 } 28 } 29 if len(errs) > 0 { 30 return fmt.Errorf("%s", strings.Join(errs, "\n")) 31 } 32 return nil 33 }