Stop stops containers in `services` without removing them. It calls `nerdctl stop CONTAINER_ID` to do the actual job.
(ctx context.Context, opt StopOptions, services []string)
| 37 | // Stop stops containers in `services` without removing them. It calls |
| 38 | // `nerdctl stop CONTAINER_ID` to do the actual job. |
| 39 | func (c *Composer) Stop(ctx context.Context, opt StopOptions, services []string) error { |
| 40 | serviceNames, err := c.ServiceNames(services...) |
| 41 | if err != nil { |
| 42 | return err |
| 43 | } |
| 44 | // reverse dependency order |
| 45 | for _, svc := range strutil.ReverseStrSlice(serviceNames) { |
| 46 | containers, err := c.Containers(ctx, svc) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | if err := c.stopContainers(ctx, containers, opt); err != nil { |
| 51 | return err |
| 52 | } |
| 53 | } |
| 54 | return nil |
| 55 | } |
| 56 | |
| 57 | func (c *Composer) stopContainers(ctx context.Context, containers []containerd.Container, opt StopOptions) error { |
| 58 | var timeoutArg string |
no test coverage detected