Fork me on GitHub
#docker
<
2023-07-05
>
joakimen10:07:59

Hi! I'm trying to figure out how to provide filters when listing containers and images with https://github.com/lispyclouds/contajners. (docs: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerList). Example: Get first 3 containers with status exited

(let [client (c/client {:engine :docker
                        :version "v1.41"
                        :conn {:uri "unix:///var/run/docker.sock"}
                        :category :containers})]
  (c/invoke client {:op :ContainerList
                    :params {:limit 3
                             :filters {:status ["exited"]}}}))
Here I get this error
{:message "invalid character ':' looking for beginning of object key string"}
The :limit query param works as expected, but I can't figure out what to give to :filters. I've tried the following formats
{:filters {:status ["exited"]}}
{:filters {:status "exited"}}
{:filters {"status""exited"}}
{:filters {'status "exited"}}
{:filters ["status=exited]"]} ;; the docker cli syntax
With no luck. Anyone has a working example of how to provide filters? Thanks in advance 🙂

lispyclouds10:07:02

Diese Nachricht enthält interaktive Elemente.

joakimen10:07:42

I think I tried that very manually yesterday, but I'll give it a try when I'm home and report back :)

1
lispyclouds10:07:58

tried now with

(invoke client
          {:op :ContainerList
           :params {:limit 3
                    :filters "{\"status\": [\"exited\"]}"}})
seems to work

lispyclouds10:07:15

i ran on Podman now, but should work fine on Docker too