Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

docker compose ps does not list stopped containers and their exit status #1671

Closed

Description

@petr-ujezdsky

Description
I have found that there are some differences between docker-compose ps and docker-compose ps regarding to stopped containers (when you docker compose stop some-service1):

Here it is listed (old version)

$ docker-compose ps
              Name                            Command                  State                                 Ports
--------------------------------------------------------------------------------------------------------------------------------------------
...
some-service1                      /usr/sbin/entrypoint.sh /t ...   Exit 137
some-service2                      /usr/sbin/entrypoint.sh /t ...   Exit 0

Here it is not listed (new version)

$ docker compose ps
NAME                               SERVICE                 STATUS              PORTS
...

You can force it using the -a parameter, but I am not sure if there won't be any other containers listed in other scenarios (eg. run command).
Note that also both containers are flagged as unhealthy even though the second one ended gracefully (Exit 0).

$ docker compose ps -a
NAME                               SERVICE                 STATUS               PORTS
some-service1                      some-service1           exited (unhealthy)
some-service2                      some-service2           exited (unhealthy)
$ docker compose ps --help

Usage:  docker compose ps

List containers

Options:
  -a, --all             Show all stopped containers (including those created by the run command)
      --format string   Format the output. Values: [pretty | json]. (default "pretty")
  -q, --quiet           Only display IDs
      --services        Display services

Steps to reproduce the issue:

  1. run commands listed above

Describe the results you received:
Different output in newer version

Describe the results you expected:
Same output as in older version

Output of docker version:
I am using docker-for-mac:

$ docker version
Client:
 Cloud integration: 1.0.14
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c289
 Built:             Fri Apr  9 22:46:57 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0```

Activity

  1. ndeloof commented on May 17, 2021

    @ndeloof
    Collaborator

    Lack of stopped services in compose ps command has been fixed by #1649 (released in "Cloud integration" 1.0.15)

    The STATUS column indeed doesn't show the exit status for service, but the health-check status which isn't relevant for exited containers. We should fix this

  2. self-assigned this
    on May 17, 2021
  3. petr-ujezdsky commented on May 18, 2021

    @petr-ujezdsky
    Author

    @ndeloof thanks for such a quick fix :)
    One question - will the exit status be listable somehow? If the container stops, I would like to know the reason. The exit status is the first think I would look at.
    For example out-of-memory has its own exit status and many other problems too I presume.

  4. ndeloof commented on May 18, 2021

    @ndeloof
    Collaborator

    yes, compose ps now prints exited (code) in STATE column for exited/died containers

  5. gabrieldemarmiesse commented on May 27, 2021

    @gabrieldemarmiesse

    It seems the UX is different from docker ps where stopped containers are not listed unless you add the -a argument. I spent quite some time on a bug because I assumed that docker compose ps would not show stopped containers like docker ps.

    Maybe we could consider aligning docker ps and docker compose ps 's behavior?

  6. ndeloof commented on May 27, 2021

    @ndeloof
    Collaborator

    @gabrieldemarmiesse sure, but here we need to embrace docker-compose legacy, which decided to use the -a flag for another purpose.

  7. gabrieldemarmiesse commented on May 27, 2021

    @gabrieldemarmiesse

    Of course, I understand what you mean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

compatibilityCompatibility with docker-compose

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions