Fork me on GitHub
#docker
<
2021-01-14
>
austin.chamberlin15:01:05

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

austin.chamberlin15:01:41

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" ""}
              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       ""
                                     :X-Registry-Auth auth}
                  :throw-exception? true})