diff --git a/local/compose/ps.go b/local/compose/ps.go index d2ee7c35d..99cd6c139 100644 --- a/local/compose/ps.go +++ b/local/compose/ps.go @@ -26,7 +26,11 @@ 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, options.Services...) + oneOff := oneOffExclude + if options.All { + oneOff = oneOffInclude + } + containers, err := s.getContainers(ctx, projectName, oneOff, true, options.Services...) if err != nil { return nil, err } diff --git a/local/compose/ps_test.go b/local/compose/ps_test.go index 619bd33fb..3ea5faac1 100644 --- a/local/compose/ps_test.go +++ b/local/compose/ps_test.go @@ -37,7 +37,9 @@ func TestPs(t *testing.T) { tested.apiClient = api ctx := context.Background() - listOpts := apitypes.ContainerListOptions{Filters: filters.NewArgs(projectFilter(testProject)), All: false} + args := filters.NewArgs(projectFilter(testProject)) + args.Add("label", "com.docker.compose.oneoff=False") + listOpts := apitypes.ContainerListOptions{Filters: args, All: true} c1, inspect1 := containerDetails("service1", "123", "Running", "healthy") c2, inspect2 := containerDetails("service1", "456", "Running", "") c2.Ports = []apitypes.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}}