I am aware that you can use curl <registry name>:5009/v2/_catalog
to list images.
From this: https://docs.docker.com/registry/deploying/#storage-customization
Is is stated "By default, the registry stores its data on the local filesystem", but where is that. -I am running Docker For Mac?
I just want an easy way to delete local images, and maybe it is a matter of finding this default host location - yes I looks like I could just use a custom volume.
I am still curious to where this default storage is located.
Is is stated "By default, the registry stores its data on the local filesystem", but where is that. -I am running Docker For Mac?
By default inside the container it's at /var/lib/registry
. Each container gets its own read/write layer as part of the overlay filesystem (all of the image layers are read-only). This is stored within /var/lib/docker
on the docker host, probably under a container or overlay sub directory, and then under a unique directory name per container. And then that, within Docker Desktop on Mac, is within a VM. You could probably exec into the container to see this path, but I wouldn't recommend modifying the contents directly for your request.
I just want an easy way to delete local images, and maybe it is a matter of finding this default host location - yes I looks like I could just use a custom volume.
First, just to verify you mean deleting images in the registry and not on the local docker engine. If the latter, you can run docker image prune
.
Assuming you have a need to run a registry server, you'll want to pass the setting REGISTRY_STORAGE_DELETE_ENABLED=true
to the registry (as an environment variable, or by setting the associated yaml config). Then you can call the manifest delete API. You'll want to get the digest and then call
curl -X DELETE http://<registry>:5000/v2/<repo>/manifests/<digest>
Once that's done, you need to run a garbage collection on the registry while no writes are occurring (by setting the server to read-only, picking an idle time, or stopping the registry and running a separate container against the same volume):
docker exec registry /bin/registry garbage-collect /etc/docker/registry/config.yml --delete-untagged
For simplifying the API calls, I've got a regclient project that includes regctl image delete ...
and regctl tag delete ...
(the latter only deleting one tag even if the manifest is referenced multiple times). And if you want to automate a cleanup policy, there's regclient/regbot
in that same project that lets you define your own cleanup policy.