better-docker-ps
better-docker-ps copied to clipboard
Feature: docker compose ps
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.
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/
Wouldn't reading the output directly from docker compose ps be enough?
Wouldn't reading the output directly from
docker compose psbe enough?
No, either I would:
- simple directly print the
docker compose psoutput (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)
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?
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.