Skip to content

Instantly share code, notes, and snippets.

@Ferada
Created February 18, 2023 08:24
Show Gist options
  • Save Ferada/0dce5d3d4d1dd457767dd6978696d928 to your computer and use it in GitHub Desktop.
Save Ferada/0dce5d3d4d1dd457767dd6978696d928 to your computer and use it in GitHub Desktop.
Docker Engine API with SBCL, drakma & yason
(let ((socket (make-instance 'sb-bsd-sockets:local-socket :type :stream)))
(sb-bsd-sockets:socket-connect socket "/var/run/docker.sock")
(with-open-stream (stream (sb-bsd-sockets:socket-make-stream socket
:element-type '(unsigned-byte 8)
:input T
:output T
:buffering :none))
(let ((wrapped-stream (flexi-streams:make-flexi-stream (drakma::make-chunked-stream stream)
:external-format drakma::+latin-1+)))
(multiple-value-bind (first second third fourth fifth sixth seventh)
(drakma:http-request "http://localhost/v1.41/images/json"
:stream wrapped-stream
:want-stream T
:force-binary T)
(unwind-protect
(let ((yason:*parse-object-as* :alist))
(yason:parse first))
(when sixth
(close first)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment