better-docker-ps icon indicating copy to clipboard operation
better-docker-ps copied to clipboard

Feature: docker compose ps

Open TKperson opened this issue 2 years ago • 5 comments
trafficstars

A lot of times, docker compose ps looks as worse as docker ps. Can you make this program work with docker compose ps too?

Adding --compose flag and have that aliased to docker compose ps in the shell configuration files should be sufficient.

TKperson avatar Jul 07 '23 19:07 TKperson

Hmm, is their a relatively easy way to get the data of docker compose ps ?
I'm not executing the docker binary under the hood, but query the data directly via the docket socket [1].

I guess I could add a filter on the label com.docker.compose.project, but then the user would have to manually insert the project name.
I definitely don't want to add parsing code for the dockercompose.yml, this is a relatively small and simple project and should stay that way.

But if anyone want to add a filter docker-compose filter (aka only show container with this specific project label), I guess that could be in-scope.
If you want you can create a PR and I'll look at it.

[1] https://docs.docker.com/registry/spec/api/

Mikescher avatar Jul 09 '23 10:07 Mikescher

Wouldn't reading the output directly from docker compose ps be enough?

TKperson avatar Jul 09 '23 18:07 TKperson

Wouldn't reading the output directly from docker compose ps be enough?

No, either I would:

  • simple directly print the docker compose ps output (but then what's the point)
  • parse the docker compose output (ugh, thats not really a good or stable format to parse)

also I display potentially more data than the default docker compose ps output prints (networks, labels, etc)

Mikescher avatar Jul 10 '23 07:07 Mikescher

You can do this with regular docker ps like this:

docker ps --filter "label=com.docker.compose.project=$PROJECT_NAME"

the filter flag here doesn't seem to work exactly the same?

this command:

dops --filter "label=com.docker.compose.project=$PROJECT_NAME"

seems to return all the containers. I think supporting the label filter would be sufficient to fix this?

quinn avatar Aug 16 '24 14:08 quinn

Looking thru your code, it looks like you just handoff the filter to the docker API. Not sure why this isn't working, maybe docker ps does something special to handle the label filters.

quinn avatar Aug 16 '24 14:08 quinn