I have several docker-compose.yml
files, running ok with docker-compose up
, individually.
Each docker-compose runs several containers.
After they are up, I can’t see what containers are up with docker ps
.
I can see something with docker-compose ps
, but only for a specific docker-compose.yml.
I want access to global polling of the containers state.
How can I list all running containers, no matter their origin?
2
Answers
Here is kind of a guess based on the clues of your question.
When you do run containers via
docker-compose up
, please do mind that hitting CTRL+C will actually stop your containers.Here is an example of doing this:
The important part here being:
^CGracefully stopping...
If you want to keep them running, you will have to run
docker-compose up
in a detached mode, with the help of the-d
option.Source: https://docs.docker.com/compose/reference/up/
So doing,
Should actually give you what you expected.
E.g.:
And if you want to see all container, regardless of their state, you can use the
-a
option ofdocker ps
.Source: https://docs.docker.com/engine/reference/commandline/ps/
E.g.:
Docker compose adds labels to each container that it creates. If you want to get all containers created by compose, you can perform a container ls and apply a filter.
This will show all running container created by compose, regardless of the project name.
For example, I created some containers from different compose projects. With the filter, I get only those, but no other container that have not been created by compose and therefore don’t have a project label.
If you want to see all container regardless of their state, you can add the
--all
or short-a
flag to the ls command, like I did in my example. Otherwise, only running containers are shown.