I am trying to figure out the solution for the above question. I tried the commands docker ps -a -f "label=redis"
and docker ps -f "name=redis"
, but that didn't gave any output.
Any help?
I think you want the ancestor
filter :
From the Docker Docs on ps
:
ancestor
- Filters containers which share a given image as an ancestor. Expressed asimage-name[:<tag>]
,image id
, orimage@digest
$docker run -d --rm redis
c4cf36467d63c66f7d3d8271dd0f8e51ede4a627048eb5e294a2445f5b0d30ef
$ docker ps -f "ancestor=redis"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4cf36467d63 redis "docker-entrypoint.s…" 16 seconds ago Up 15 seconds 6379/tcp elated_yonath