MCPcopy Create free account
hub / github.com/containerd/nerdctl / Remove

Method Remove

pkg/composer/rm.go:42–64  ·  view source on GitHub ↗

Remove removes stopped containers in `services`.

(ctx context.Context, opt RemoveOptions, services []string)

Source from the content-addressed store, hash-verified

40
41// Remove removes stopped containers in `services`.
42func (c *Composer) Remove(ctx context.Context, opt RemoveOptions, services []string) error {
43 serviceNames, err := c.ServiceNames(services...)
44 if err != nil {
45 return err
46 }
47 // reverse dependency order
48 for _, svc := range strutil.ReverseStrSlice(serviceNames) {
49 containers, err := c.Containers(ctx, svc)
50 if err != nil {
51 return err
52 }
53 if opt.Stop {
54 // use default Options to stop service containers.
55 if err := c.stopContainers(ctx, containers, StopOptions{}); err != nil {
56 return err
57 }
58 }
59 if err := c.removeContainers(ctx, containers, opt); err != nil {
60 return err
61 }
62 }
63 return nil
64}
65
66func (c *Composer) removeContainers(ctx context.Context, containers []containerd.Container, opt RemoveOptions) error {
67 args := []string{"rm", "-f"}

Callers

nothing calls this directly

Calls 5

ServiceNamesMethod · 0.95
ContainersMethod · 0.95
stopContainersMethod · 0.95
removeContainersMethod · 0.95
ReverseStrSliceFunction · 0.92

Tested by

no test coverage detected