(in-package #:nekod.docker) (defun pull-image (sock name &optional (tag "latest")) "Pull a Docker image from a registry. name — image name, e.g. \"nginx\" or \"registry.example.com/myapp\" tag — image tag, defaults to \"latest\" Returns the event stream body as a string." (docker-post sock (format nil "/images/create?fromImage=~a&tag=~a" name tag))) (defun list-images (sock &optional (all nil)) "List locally available Docker images. all=t includes intermediate images. Returns JSON body as a string." (multiple-value-bind (status body) (docker-get sock (format nil "/images/json?all=~a" (if all 1 0))) (if (= status 200) body (error 'nekod:docker-api-error :message body :status-code status :endpoint "/images/json")))) (defun inspect-image (sock id) "Inspect a Docker image by ID or name. Returns full JSON metadata as a string." (multiple-value-bind (status body) (docker-get sock (format nil "/images/~a/json" id)) (if (= status 200) body (error 'nekod:docker-api-error :message body :status-code status :endpoint (format nil "/images/~a/json" id))))) (defun remove-image (sock id &optional (force nil) (no-prune nil)) "Remove a Docker image by ID or name. force — force removal even if the image is in use no-prune — do not delete untagged parent images Returns JSON body on success." (multiple-value-bind (status body) (docker-delete sock (format nil "/images/~a?force=~a&noprune=~a" id (if force "true" "false") (if no-prune "true" "false"))) (if (member status '(200 204)) body (error 'nekod:docker-api-error :message body :status-code status :endpoint (format nil "/images/~a" id))))) (defun tag-image (sock id repo tag) "Re-tag a Docker image. id — source image ID or name repo — target repository name tag — target tag Returns t on success." (multiple-value-bind (status body) (docker-post sock (format nil "/images/~a/tag?repo=~a&tag=~a" id repo tag)) (if (= status 201) t (error 'nekod:docker-api-error :message body :status-code status :endpoint (format nil "/images/~a/tag" id))))) (defun prune-images (sock) "Remove all dangling (untagged, unreferenced) images. Returns JSON summary as a string." (multiple-value-bind (status body) (docker-post sock "/images/prune") (if (= status 200) body (error 'nekod:docker-api-error :message body :status-code status :endpoint "/images/prune"))))