Yea they didn't make this easy and it's still not perfect, but the v2 registry API now has the ability to delete images.
Can I simply and savely just remove the folder v2/repositories/IMAGE_NAME/_manifests/tags/VERSION
The actual image data is stored in the blobs directory on disk but they are shared between different manifests so it's not safe to just purge that directory out unless you've considered all images that may share the blobs.
Here is the method to delete an image using the v2 docker API:
Firstly, your registry has to have DELETE enabled.
Either set the env var:
or in the config.yml have to set
Next, run the deletion via API calls (You can easily test via Postman or just using curl/etc)
NOTE: In the below calls, add
"Accept: application/vnd.docker.distribution.manifest.v2+json" to the HTTP Header
Gather image digest:
This call returns the header key
Docker-Content-Digest with a value like this:
Using that value from step 2, run the
DELETE http call:
Run garbage collection manually if you don't want to wait for its next scheduled run:
registry garbage-collect /etc/docker/registry/config.yml
Example if running registry as a container:
docker exec -t registry-test ./bin/registry garbage-collect /etc/docker/registry/config.yml
Garbage collector deletes the associated blobs and manifests from disk for you.
At this point the image:tag is completely deleted from disk and is purged from the registry. The blobs are deleted and you'll see the manifests gone from
NOTE: If this was the last image in your repo, you still have to manually delete the repo listing from disk (
v2/repositories/<image_name>/_layers) - however this is just metadata. The actual image data has already been removed. I believe this might be a bug in the garbage collector. I have a question about it here: Docker Private Registry - Deleted all images, but still showing in catalog