Sorry for this seems to be the very basic question, but somehow I just can’t make it work.
In my most recently updated ubuntu22.04, I installed nexus3:latest (I think it is 3.78.2) so to use it as a docker repo. I used this command:
docker run -d --name nexus -p 8081:8081 -p 8082:8082 -v /opt/nexus-data:/nexus-data --restart unless-stopped sonatype/nexus3
Everything works fine: I can login to the UI, login as admin and then change password. I am create a docker hosted repo and put a docker image into this repo, and pull it, via docker push/pull and curl/API. But I could not delete it (I had this problem with my 8+ year old nexus docker container, in which I could not find a way to delete, and this is the reason I am trying to upgrade to ubuntu22.04 + latest nexus3). Chatgpt said I should do something like this:
get the digest first. This works for me:
curl -s -u admin -X GET -I -H “Accept: application/vnd.docker.distribution.manifest.v2+json” http://:8082/v2/dockerepo2204/my_docker_img/manifests/latest | grep “Docker-Content-Digest”
===> Docker-Content-Digest: sha256:dd1c2b2f417713a3cfcb44af6c62fba79feb0453eccbfcd87ccf5f1d8e012997
use this command to delete.
curl -u admin -X DELETE http://<my_ip>:8082/v2/dockerepo2204/my_docker_img/manifests/sha256:dd1c2b2f417713a3cfcb44af6c62fba79feb0453eccbfcd87ccf5f1d8e012997
This doesn’t work. Nothing returned. In face, If I change the digest 2997 to 2999, a random digest, nothing is reported as well.
Chatgpt then told me that I have to set ‘“allowDeleteApi”: true’. But the way it provided, neither UI or curl way worked for me.
So my question: how do I delete a docker image in sonatype/nexus3 docker repo programmatically (not via UI) so I can automatic this step? Any related API pointers or a working example would be very helpful.
Sorry if this question was asked and answered before. I did a quick search but could not find the answer. Thank you!
I am confused by the waiting. I was told that after my first successful post, follow-up post will be accepted automatically. This is not my first post. What it is waited again? Thanks.
Sorry, I meant that nothing is shown in the screen after running that command. I should have used the -i option for curl. I can’t see the other claim I made that changing the digests to a random value doesn’t output anything.
to delete a docker image. The difference is: using the first/components, in the UI you can still see the deleted image, but the second/manifests way UI is cleaned up. In both cases, the blobs are not cleaned up.
So my follow-up questions, for the goal of the original task (delete an docker image completely):
are these two ways both supported? If yes, what’s the difference exactly (other than the above observation)?
more importantly, how to clean the data/blobs after these commands so I can reclaim my disk space?
Again, from Chatgpt, I got this:
To clean up:
Wait 1 day (blobs must be unused for 24h)
Run a “Admin - Compact blob store” task in Nexus
Is this the right step? There are so many different task types and I am not sure exactly who is what.
Hi Karl,
To fully delete the docker image from the blob store disk, you need to setup two admin tasks in gui to delete it fully. Read through the " Required Final Steps to Completely Delete Docker Assets From Disk" at https://support.sonatype.com/hc/en-us/articles/360009696054-How-to-delete-docker-images-from-Nexus-Repository-3 . Have those two tasks run in order to reclaim the space from the blob store disk. You might also probably want to setup a task for “Docker - Delete incomplete uploads” before running the other two as well to cleanup any images that were incomplete.