How to filter docker process based on image
Solution 1:
Use "ancestor" instead of "image" that works great. Example:
sudo -S docker ps -q --filter ancestor=docker-mariadb:1.0.1
The Docker team may have added it in the last versions: http://docs.docker.com/engine/reference/commandline/ps/
Solution 2:
You can use awk
and grep
to filter specified container id.
For example:
docker ps | grep "docker-mariadb:1.0.1" | awk '{ print $1 }'
This will print id of your container.
Solution 3:
docker ps -a | awk '{ print $1,$2 }' | grep imagename | awk '{print $1 }'
This is perfect. if you need you can add a filter of running images of a particular stsatus alone, like below
docker ps -a --filter=running | awk '{ print $1,$2 }' | grep rulsoftreg:5000/mypayroll/cisprocessing-printdocsnotifyconsumer:latest | awk '{print $1 }'
Various other filter options can be explored here
https://docs.docker.com/v1.11/engine/reference/commandline/ps/