docker

2021-01-14T15:23:05.000900Z

Does anybody have an example of using clj-docker-client 1.x with a registry that requires authentication?

2021-01-14T15:46:41.001200Z

for the record:

(ns dclj.core
  (:require [clj-docker-client.core :as d]
            [cheshire.core :as json])
  (:import java.util.Base64))

(defn b64-encode [to-encode]
  (.encodeToString (Base64/getEncoder) (.getBytes to-encode)))

(def auth (-> {"username" "un"
               "password" "pw"
               "serveraddress" "<http://docker.acme.com|docker.acme.com>"}
              json/encode
              b64-encode))

(def images (d/client {:category :images
                       :conn     {:uri "unix:///var/run/docker.sock"}
                       :api-version "v1.40"}))

(d/invoke images {:op               :ImageCreate
                  :params           {:fromImage       "<http://docker.acme.com/eg:2.1.995|docker.acme.com/eg:2.1.995>"
                                     :X-Registry-Auth auth}
                  :throw-exception? true})