Skip to content

Add ps subcommand to list project containers - #141

Open
adrum wants to merge 2 commits into
Mcrich23:mainfrom
adrum:feat/compose-ps
Open

adrum wants to merge 2 commits into
Mcrich23:mainfrom
adrum:feat/compose-ps

Conversation

@adrum

@adrum adrum commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Lists the compose project's containers in an aligned NAME/IMAGE/STATUS/PORTS table, showing only running containers unless -a/--all is passed. Containers are matched primarily by the com.docker.compose.project/service labels stamped since #126 (reliable across naming modes), falling back to the candidate container names for containers created before the labels existed.

Resolves the project through the shared ComposeProjectOptions (#138) and fails fast on unknown service names with the noSuchService contract #139 established for up.

Lists the compose project's containers in an aligned
NAME/IMAGE/STATUS/PORTS table, showing only running containers unless
-a/--all is passed. Containers are matched primarily by the
com.docker.compose.project/service labels stamped since Mcrich23#126 (reliable
across naming modes), falling back to the candidate container names for
containers created before the labels existed.

Resolves the project through the shared ComposeProjectOptions (Mcrich23#138)
and fails fast on unknown service names with the noSuchService
contract Mcrich23#139 established for up.
@Mcrich23

Mcrich23 commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Sorry for the slow response! I wasn't able to work on open source for most of the summer, but I'm catching up now. This is a useful addition.

One issue: the name fallback can include a container whose labels identify it as belonging to another project. Can you limit that fallback to containers without project labels? Please add coverage for project filtering, service filtering, and stopped containers.

A container labeled for a different project could be included when its
name collided with one of our candidate names (e.g. project demo +
service web-x produce the candidate demo-web-x, which is also the name
project demo-web gives its service x). Labels are now authoritative
whenever present; the candidate-name fallback applies only to
containers without compose labels (created before Mcrich23#126 stamped them).

Extracts the selection into ComposePs.select, generic over the
container representation, with unit coverage for project filtering,
service filtering, the unlabeled fallback, and stopped-container
visibility with and without --all.
@adrum

adrum commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

I added the fallback to limit to those without compose labels. Also added tests for project filtering, service filtering, and stopped containers.

I also noticed up/down's pre-start/stop cleanup has the same issue in regards to labels. We can address that in a future PR.

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.

2 participants