By command, we can use many --filter to specify many labels for "docker ps". But containers.list() did not show this option to specify multiple labels. How to use multiple lables?
` def list(self, all=False, before=None, filters=None, limit=-1, since=None,
sparse=False, ignore_removed=False):
"""
List containers. Similar to the docker ps command.
Args:
all (bool): Show all containers. Only running containers are shown
by default
since (str): Show only containers created since Id or Name, include
non-running ones
before (str): Show only container created before Id or Name,
include non-running ones
limit (int): Show `limit` last created containers, include
non-running ones
filters (dict): Filters to be processed on the image list.
Available filters:
- `exited` (int): Only containers with specified exit code
- `status` (str): One of ``restarting``, ``running``,
``paused``, ``exited``
- `label` (str): format either ``"key"`` or ``"key=value"``
- `id` (str): The id of the container.
- `name` (str): The name of the container.
- `ancestor` (str): Filter by container ancestor. Format of
``<image-name>[:tag]``, ``<image-id>``, or
``<image@digest>``.
- `before` (str): Only containers created before a particular
container. Give the container name or id.
- `since` (str): Only containers created after a particular
container. Give container name or id.
A comprehensive list can be found in the documentation for
`docker ps
<https://docs.docker.com/engine/reference/commandline/ps>`_.`
Hello @GodQ it is possible to query multiple labels by passing a list with the label key in the filters dictionary.
For instance
client.containers.list(filters={"label":["foo=1", "bar=2"]})
This is equivalent to
docker ps -f label="foo=1" -f label="bar=2"
Hello @GodQ it is possible to query multiple labels by passing a list with the label key in the filters dictionary.
For instanceclient.containers.list(filters={"label":["foo=1", "bar=2"]})This is equivalent to
docker ps -f label="foo=1" -f label="bar=2"
Thank you very much!
Issue resolved
Most helpful comment
Hello @GodQ it is possible to query multiple labels by passing a list with the label key in the filters dictionary.
For instance
This is equivalent to