Home

Awesome

pod-lispyclouds-docker

A babashka pod for interacting with docker. Uses the clj-docker-client to function.

DEPRECATION NOTICE: contajners is recommended to use instead of this pod. It is source compatible with babashka and supports much more features and has less limitations as compared to the this pod. Also more engines like podman are supported. This codebase won't receive any further updates.

Building prerequisites

Building

Installing GraalVM:

Clone the repo and from the repo directory:

Usage

Sample script to pull an image, create a container and fetch its logs

(require '[babashka.pods :as pods])

;; Assumes pod-lispyclouds-docker is on the PATH.
(pods/load-pod ["pod-lispyclouds-docker"])

(require '[pod.lispyclouds.docker :as docker])

(def images (docker/client {:category :images
                            :conn     {:uri "unix:///var/run/docker.sock"}}))

(def containers (docker/client {:category :containers
                                :conn     {:uri "unix:///var/run/docker.sock"}}))

;; pull the "busybox:musl" image
(docker/invoke images {:op     :ImageCreate
                       :params {:fromImage "busybox:musl"}})

;; create a container called "conny" from it
(docker/invoke containers {:op     :ContainerCreate
                           :params {:name "conny"
                                    :body {:Image "busybox:musl"
                                           :Cmd   ["echo" "hello"]}}})

(docker/invoke containers {:op     :ContainerStart
                           :params {:id "conny"}})

(def logs (docker/invoke containers {:op     :ContainerLogs
                                     :params {:id     "conny"
                                              :stdout true}}))

(println logs)