Search code examples
bashdockerdocker-containerlsof

Could I list all running docker-compose files?


I was wondering if it would be possible to list all running docker-compose files with a bash function? Something like docker ps or docker container ls, but I want it to show the files only.

I got started with this - lsof | egrep 'REG|DIR' | awk '{print $9}' but this provides me tons of unwanted information as well.

What would be the best approach here?

Thanks in advance.


Solution

  • So I played around with docker inspect and came up with that:

    for c in `docker ps -q`; do echo $c; docker inspect $c --format '{{index .Config.Labels "com.docker.compose.project.config_files"}}' ; done
    

    So it is possible ;)