registry:2.5.0版本的鏡像,將鏡像默認存放在了/var/lib/registry
目錄下 /var/lib/registry/Docker/registry/v2/repositories/
目錄下會有幾個文件夾,命名是已經上傳了的鏡像的名稱。
若是須要刪除已經上傳的鏡像,現有兩種方法docker
1.官方推薦版重點內容json
1) 更改registry容器內/etc/docker/registry/config.yml文件app
storage: delete: enabled: true
2) 找出你想要的鏡像名稱的tagcurl
$ curl -I -X GET <protocol>://<registry_host>/v2/<鏡像名>/tags/list
3) 拿到digest_hash參數ide
$ curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET http://<倉庫地址>/v2/<鏡像名>/manifests/<tag>
如:wordpress
$ curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X GET http://10.109.252.221:5000/v2/wordpress/manifests/latest
4) 複製digest_hashurl
Docker-Content-Digest: <digest_hash>
5) 刪除清單.net
$ curl -I -X DELETE <protocol>://<registry_host>/v2/<repo_name>/manifests/<digest_hash>
如:code
$ curl -I -X DELETE http://10.109.252.221:5000/v2/wordpress/manifests/sha256:b3a15ef1a1fffb8066d0f0f6d259dc7f646367c0432e3a90062b6064f874f57c
6) 刪除文件系統內的鏡像文件,注意2.4版本以上的registry纔有此功能get
$ docker exec -it <registry_container_id> bin/registry garbage-collect <path_to_registry_config>
如:
$ docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml
2.簡易版
1.打開鏡像的存儲目錄,若有-V操做打開掛載目錄也能夠,刪除鏡像文件夾
$ docker exec <容器名> rm -rf /var/lib/registry/docker/registry/v2/repositories/<鏡像名>
2.執行垃圾回收操做,注意2.4版本以上的registry纔有此功能
$ docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml