diff --git a/pkg/compose/ps.go b/pkg/compose/ps.go index 4c7eaac98..80cbfca2b 100644 --- a/pkg/compose/ps.go +++ b/pkg/compose/ps.go @@ -32,7 +32,7 @@ func (s *composeService) Ps(ctx context.Context, projectName string, options api if options.All { oneOff = oneOffInclude } - containers, err := s.getContainers(ctx, projectName, oneOff, true, options.Services...) + containers, err := s.getContainers(ctx, projectName, oneOff, options.All, options.Services...) if err != nil { return nil, err } diff --git a/pkg/compose/ps_test.go b/pkg/compose/ps_test.go index 9a03a88ec..61fb528f4 100644 --- a/pkg/compose/ps_test.go +++ b/pkg/compose/ps_test.go @@ -46,7 +46,7 @@ func TestPs(t *testing.T) { ctx := context.Background() args := filters.NewArgs(projectFilter(strings.ToLower(testProject))) args.Add("label", "com.docker.compose.oneoff=False") - listOpts := moby.ContainerListOptions{Filters: args, All: true} + listOpts := moby.ContainerListOptions{Filters: args, All: false} c1, inspect1 := containerDetails("service1", "123", "running", "healthy", 0) c2, inspect2 := containerDetails("service1", "456", "running", "", 0) c2.Ports = []moby.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}} diff --git a/pkg/e2e/ps_test.go b/pkg/e2e/ps_test.go index 246648413..b9439de93 100644 --- a/pkg/e2e/ps_test.go +++ b/pkg/e2e/ps_test.go @@ -94,4 +94,18 @@ func TestPs(t *testing.T) { } assert.Equal(t, 2, count, "Did not match both services:\n"+res.Combined()) }) + + t.Run("ps --all", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "--project-name", projectName, "stop") + assert.NoError(t, res.Error) + + res = c.RunDockerComposeCmd(t, "-f", "./fixtures/ps-test/compose.yaml", "--project-name", projectName, "ps") + lines := strings.Split(res.Stdout(), "\n") + assert.Equal(t, 2, len(lines)) + + res = c.RunDockerComposeCmd(t, "-f", "./fixtures/ps-test/compose.yaml", "--project-name", projectName, "ps", "--all") + lines = strings.Split(res.Stdout(), "\n") + assert.Equal(t, 4, len(lines)) + }) + }