批量删除Nexus Repository Manager镜像
作者写了一个批量删除docker镜像的脚本,可以通过image name和tag进行匹配,该脚本是根据官网的提供的查询和删除Component的REST接口,批量删除docker image 对应的Component,最终还是要执行一下清理unused images和clear blob的Task。
该脚本作者在Ubuntu 16.04和镜像sonatype/nexus3:3.16.0下使用,其他版本或有不同,不能使用可查看官网REST API修改。
脚本下载
将下载的tar包放到服务器上,执行一下命令
tar -xvf nexus-clean.tar
chmod -R 555 ./nexus-clean
mv ./nexus-clean/clean-cli ./nexus-clean/jq /usr/local/bin/
直接运行 clean-cli 命令
Tips:
- 脚本中Nexus Repository Manager ui端口固定为8081,没有作为自定义参数输入;
- Image name和image tag必须输入一个,也可以同时输入
创建并执行task删除镜像文件
接下来依次手动执行两个task就可以了:
- Delete unused manifests and images
- Compact blob store