docker

joakimen 2023-07-05T10:30:59.890489Z

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 πŸ™‚

βœ… 1
lispyclouds 2023-07-05T10:35:02.226079Z

Diese Nachricht enthΓ€lt interaktive Elemente.

joakimen 2023-07-05T10:39:42.431949Z

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

πŸ‘πŸΎ 1
lispyclouds 2023-07-05T10:45:58.821649Z

tried now with

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

lispyclouds 2023-07-05T10:48:15.821009Z

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

joakimen 2023-07-05T10:59:30.480519Z

Confirmed working on Docker as well mario-star

:filters (json/generate-string {:status ["exited" "dead"]})
Thanks a lot πŸ™‡

πŸŽ‰ 1