Skip to content
This repository has been 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
petr-ujezdsky opened this issue May 14, 2021 · 6 comments · Fixed by #1675
Closed

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

petr-ujezdsky opened this issue May 14, 2021 · 6 comments · Fixed by #1675
Assignees
Labels
compatibility Compatibility with docker-compose

Comments

@petr-ujezdsky
Copy link

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```

@ndeloof
Copy link
Collaborator

ndeloof commented May 17, 2021

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

@ndeloof ndeloof self-assigned this May 17, 2021
@ndeloof ndeloof added compatibility Compatibility with docker-compose compose labels May 17, 2021
@petr-ujezdsky
Copy link
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.

@ndeloof
Copy link
Collaborator

ndeloof commented May 18, 2021

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

@gabrieldemarmiesse
Copy link

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?

@ndeloof
Copy link
Collaborator

ndeloof commented May 27, 2021

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

@gabrieldemarmiesse
Copy link

Of course, I understand what you mean

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compatibility Compatibility with docker-compose
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants