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

Function runRm

cli/command/container/rm.go:72–100  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, opts *rmOptions)

Source from the content-addressed store, hash-verified

70}
71
72func runRm(ctx context.Context, dockerCLI command.Cli, opts *rmOptions) error {
73 apiClient := dockerCLI.Client()
74 errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, ctrID string) error {
75 ctrID = strings.Trim(ctrID, "/")
76 if ctrID == "" {
77 return errors.New("container name cannot be empty")
78 }
79 _, err := apiClient.ContainerRemove(ctx, ctrID, client.ContainerRemoveOptions{
80 RemoveVolumes: opts.rmVolumes,
81 RemoveLinks: opts.rmLink,
82 Force: opts.force,
83 })
84 return err
85 })
86
87 var errs []error
88 for _, name := range opts.containers {
89 if err := <-errChan; err != nil {
90 if opts.force && errdefs.IsNotFound(err) {
91 _, _ = fmt.Fprintln(dockerCLI.Err(), err)
92 continue
93 }
94 errs = append(errs, err)
95 continue
96 }
97 _, _ = fmt.Fprintln(dockerCLI.Out(), name)
98 }
99 return errors.Join(errs...)
100}

Callers 1

newRmCommandFunction · 0.85

Calls 5

parallelOperationFunction · 0.85
ContainerRemoveMethod · 0.80
ClientMethod · 0.65
ErrMethod · 0.65
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…