MCPcopy Index your code
hub / github.com/docker/cli / newKillCommand

Function newKillCommand

cli/command/container/kill.go:22–46  ·  view source on GitHub ↗

newKillCommand creates a new cobra.Command for "docker container kill"

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

20
21// newKillCommand creates a new cobra.Command for "docker container kill"
22func newKillCommand(dockerCLI command.Cli) *cobra.Command {
23 var opts killOptions
24
25 cmd := &cobra.Command{
26 Use: "kill [OPTIONS] CONTAINER [CONTAINER...]",
27 Short: "Kill one or more running containers",
28 Args: cli.RequiresMinArgs(1),
29 RunE: func(cmd *cobra.Command, args []string) error {
30 opts.containers = args
31 return runKill(cmd.Context(), dockerCLI, &opts)
32 },
33 Annotations: map[string]string{
34 "aliases": "docker container kill, docker kill",
35 },
36 ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
37 DisableFlagsInUseLine: true,
38 }
39
40 flags := cmd.Flags()
41 flags.StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
42
43 _ = cmd.RegisterFlagCompletionFunc("signal", completeSignals)
44
45 return cmd
46}
47
48func runKill(ctx context.Context, dockerCLI command.Cli, opts *killOptions) error {
49 apiClient := dockerCLI.Client()

Callers 3

newContainerCommandFunction · 0.85
TestRunKillFunction · 0.85
TestRunKillClientErrorFunction · 0.85

Calls 1

runKillFunction · 0.85

Tested by 2

TestRunKillFunction · 0.68
TestRunKillClientErrorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…