Docker Community Forums

Share and learn in the Docker community.

Is there some resource to learn about `docker ps` filters?

The official documentation for docker ps suggests that the --filter option can be used to “Filter output based on conditions provided”. However I cannot find resources that explain what kind of filters those are / how to write them.

E.g. at least for docker ps --format=someFormat, it is mentioned that the format is a Go template (I’m not too familiar with how to write those anyway, but that’s my own fault).

My specific use case calls for finding containers with a “healthy” status, but in any case I’d like to know what is the general syntax, DSL, etc. that is to be used, so that I can learn on my own if needed.

This article isn’t that useful. I’d like to see what options to pass. For example, I know I can find orphaned images with docker images -af dangling=true. What other keywords than dangling can we use? I’ve found some of these options in the source code, but I can’t find where it’s explicitly documented with examples.

Take a look at “filters” in “query parameters” here (API reference). These are the literal query parameters passed to the API but working backwards to the flags is generally pretty straightforward, e.g., --filter label=highmem=1.

I think you might want --filter status=running