Download docker/image.lisp from Snapkitty/nekomata: direct link, hf CLI and curl.
- Browser
- Download file 2.72 kB
-
https://huggingface.co/Snapkitty/nekomata/resolve/main/docker/image.lisp
- Command line
-
hf download hf://Snapkitty/nekomata/docker/image.lisp
-
curl -L -o image.lisp https://huggingface.co/Snapkitty/nekomata/resolve/main/docker/image.lisp
2.72 kB
| (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")))) | |