Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

lispyclouds/pod-lispyclouds-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • Download and extract GraalVM CE. Go to the extracted location and navigate to the directory where you can find bin, lib, jre and other directories.
  • Run export GRAALVM_HOME=$PWD.

Clone the repo and from the repo directory:

  • Run $GRAALVM_HOME/bin/gu install native-image to get the Graal native compiler.
  • Run clojure -A:native-image if using Clojure CLI or lein native-image with leiningen to compile it to a native executable.
  • The executable is found in target/ if compiled via Clojure CLI or in target/default+uberjar/ with leiningen.

Usage

  • Fire up a babashka v0.0.92+ REPL with rlwrap bb
  • Import pods: (require '[babashka.pods :as pods])
  • Load this pod: (pods/load-pod ["pod-lispyclouds-docker"]). Assumes pod-lispyclouds-docker is on the PATH.
  • Load the ns: (require '[pod.lispyclouds.docker :as docker])
  • See the Usage section to try out the commands.
  • Calling invoke with :as stream and :as :socket are unsupported at the moment.

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)

About

A babashka pod for interacting with docker

Resources

License

Stars

Watchers

Forks

Packages

No packages published