I am using go-dockerclient library to retrieve list of containers I got all containers by using the ListContainers function
conts, err := client.ListContainers(docker.ListContainersOptions{All: true})
But I want to get only containers that are running a specific image I tried running
conts, err := client.ListContainers(docker.ListContainersOptionsFilters: map[string][]string{"Image": {"<imagename>:<version>"}}})
but I got the error Invalid filter:'Image' meaning that there is no filter field called Image
So does anybody have a solution to get only containers that are running a specific image? Thank you
instead of image field you should use ancestor so you can use
conts, err :=client.ListContainers(docker.ListContainersOptionsFilters: map[string][]string{"ancestor": {"<imagename>:<version>"}}}
Just see the docker ps filter options, the website below lists all filters supported currently. https://github.com/docker/cli/blob/master/docs/reference/commandline/ps.md