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.
3
Answers
So I played around with docker inspect and came up with that:
So it is possible ;)
It is not possible to backtrack and find the docker-compose file that was used in container deployment. To overcome such issues, a project pipeline is recommended using tools like maven, jenkins, gradle etc along with a repository platform like github. If its a personal project you can organize your project by wrapping the docker deployment commands and source files in a script and only use them to create deployments. This way it will be organized to some extent.
This bash oneliner shows the working dir of each container’s compose file.
I edited kvelev’s command to get this. kvelev’s command was just printing "docker-compose.yaml" for each of my loaded containers, so I edited the filter to show the working dir, which works for me.