Created
February 18, 2023 08:24
-
-
Save Ferada/0dce5d3d4d1dd457767dd6978696d928 to your computer and use it in GitHub Desktop.
Docker Engine API with SBCL, drakma & yason
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
c.f. https://docs.docker.com/engine/api/v1.41/, https://dev.to/rajasegar/http-over-unix-sockets-in-common-lisp-4l72