diff --git a/api/compose/api.go b/api/compose/api.go index eae71aa61..be38110a1 100644 --- a/api/compose/api.go +++ b/api/compose/api.go @@ -268,7 +268,8 @@ type ListOptions struct { // PsOptions group options of the Ps API type PsOptions struct { - All bool + All bool + Services []string } // PortPublisher hold status about published port diff --git a/cli/cmd/compose/ps.go b/cli/cmd/compose/ps.go index 20e99c32a..c67ea580b 100644 --- a/cli/cmd/compose/ps.go +++ b/cli/cmd/compose/ps.go @@ -47,7 +47,7 @@ func psCommand(p *projectOptions, backend compose.Service) *cobra.Command { Use: "ps", Short: "List containers", RunE: Adapt(func(ctx context.Context, args []string) error { - return runPs(ctx, backend, opts) + return runPs(ctx, backend, args, opts) }), } psCmd.Flags().StringVar(&opts.Format, "format", "pretty", "Format the output. Values: [pretty | json].") @@ -57,13 +57,14 @@ func psCommand(p *projectOptions, backend compose.Service) *cobra.Command { return psCmd } -func runPs(ctx context.Context, backend compose.Service, opts psOptions) error { +func runPs(ctx context.Context, backend compose.Service, services []string, opts psOptions) error { projectName, err := opts.toProjectName() if err != nil { return err } containers, err := backend.Ps(ctx, projectName, compose.PsOptions{ - All: opts.All, + All: opts.All, + Services: services, }) if err != nil { return err diff --git a/local/compose/ps.go b/local/compose/ps.go index 9dc034719..d2ee7c35d 100644 --- a/local/compose/ps.go +++ b/local/compose/ps.go @@ -26,7 +26,7 @@ import ( ) func (s *composeService) Ps(ctx context.Context, projectName string, options compose.PsOptions) ([]compose.ContainerSummary, error) { - containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All) + containers, err := s.getContainers(ctx, projectName, oneOffInclude, options.All, options.Services...) if err != nil { return nil, err }