由于偷懒,在公司搭建CI时,采用了nexus统一docker repository以及maven repository。但是使用过程中发现,构建docker image过大,导致nexus空间增长迅速。但是nexus官方却没能提供一套清理空间的方案。废话不多说,直接上方案。
下载nexus-cli客户端,并非必须下载到服务器,理论上只要能访问到nexus就行
`wget https://s3.eu-west-2.amazonaws.com/nexus-cli/1.0.0-beta/linux/nexus-cli`
修改nexus-cli的访问权限
`chmod +x nexus-cli`
配置nexus的服务器地址、docker仓库名称、账号、密码
`nexus-cli configure`
显示当前仓库中所有镜像
`nexus-cli image ls`
查看某一镜像的所有的tag
`nexus-cli image tags -name IMAGE_NAME`
查看某一镜像详细信息
`nexus-cli image info -name IMAGE_NAME -tag TAG`
删除制定镜像的制定tag
`nexus-cli image delete -name IMAGE_NAME -tag TAG`
仅保留X项tag,其余全部删除
`nexus-cli image delete -name IMAGE_NAME -keep X`