# How to delete a docker image in Nexus3 Repo programmatically?

**URL:** <https://community.sonatype.com/t/how-to-delete-a-docker-image-in-nexus3-repo-programmatically/14701>\
**Category:** Sonatype Nexus Repository\
**Tags:** rest, nexus-repository\
**Created:** [March 27, 2025, 8:26pm UTC](https://community.sonatype.com/t/how-to-delete-a-docker-image-in-nexus3-repo-programmatically/14701 "2025-03-27T20:26:54Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Karl\_Cai](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@Karl\_Cai](https://community.sonatype.com/u/Karl_Cai)\
**Post date:** [March 27, 2025, 8:26pm UTC](https://community.sonatype.com/t/how-to-delete-a-docker-image-in-nexus3-repo-programmatically/14701/1 "2025-03-27T20:26:55Z")

</div>

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:

1. 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
2. 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.
3. 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!

---

_[View the full topic](https://community.sonatype.com/t/how-to-delete-a-docker-image-in-nexus3-repo-programmatically/14701)._
