Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix listing of services #9395

Closed
wants to merge 1 commit into from
Closed

fix listing of services #9395

wants to merge 1 commit into from

Conversation

bosix
Copy link

@bosix bosix commented Apr 14, 2022

What I did

Currently, when listing services in v2 (compose ps --services) only running containers are observed and listed since in the background the docker api is asked for matching containers. This pr fixes this behavior by using the full list of services provided by compose itself.

Since this is my first pr here, I would appreciate any feedback or ideas on how to better implement this. For example, I was thinking of a flag that would allow the user to select the desired behavior themselves, but since v1's service list was different, I just implemented the fix.

Related issue

The issue is described in #9391.

closes #9391

Signed-off-by: Florian Bosdorff <dev@bosdorff.de>
@ndeloof
Copy link
Contributor

ndeloof commented Apr 24, 2022

I'm not sure how compose v1 implements ps --services flag and what the initial intent was for this option, but if the intent is to just list services from compose model, then docker compose config --services command should be preferred.

@ndeloof
Copy link
Contributor

ndeloof commented Apr 24, 2022

answering my own question: this has been introduced by #5384, introduced to improve shell completion.

This change make this the exact same as docker compose config --services, while ps --services make sense because it reflect actual state of the compose application, so should be based on existing services, not just project model. i.e compose ps (--filter) return the status of a compose app, and --services option only shows involved services.

I don't have a strong opinion on the direction to choose here, maybe @glours @ulyssessouza ?

@glours
Copy link
Contributor

glours commented Jul 20, 2022

As discussed with the team in charge of Compose, we think that the purpose of docker compose ps --services --all is to list running services of a compose stack (regular services and the ones started with oneoff containers) and not to listing project model services.
As mentioned you should use docker compose config --services to do that

@glours glours closed this Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compose ps --services does not list stopped and removed containers anymore
3 participants