本文主要是介绍nexus 清理 docker 镜像,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
下载配置 nexus-cli
看网上文档都用如下地址,但现在已经不能下载:
wget https://s3.eu-west-2.amazonaws.com/nexus-cli/1.0.0-beta/linux/nexus-cli
chmod +x nexus-cli
在 github 上下载:
wget https://github.com/heyonggs/nexus-cli/releases/download/0.0.3/nexus-cli-linux
mv nexus-cli-linux /usr/local/bin/nexus-cli
chmod +x /usr/local/bin/nexus-cli
查看帮助命令
[root@nexus ~]# nexus-cli --help
NAME:Nexus CLI - Manage Docker Private Registry on NexusUSAGE:nexus-cli [global options] command [command options] [arguments...]VERSION:0.0.2AUTHOR:Eugen Mayer, Karol Buchta, Mohamed Labouardy <->COMMANDS:configure Configure Nexus Credentialsimage Manage Docker Imageshelp, h Shows a list of commands or help for one commandGLOBAL OPTIONS:--help, -h show help--version, -v print the version
配置凭证
[root@nexus ~]# nexus-cli configure
Enter Nexus Host: https://nexus.***.com
Enter Nexus Repository Name: docker-public
Enter Nexus Username: admin
Enter Nexus Password: Removed potential trailing slash on Nexus Host URL, now: https://nexus.***.com
Configuration saved to succesfully to: /root/.nexus-cli
列出所有镜像
[root@nexus ~]# nexus-cli image ls
admin/admin
ai/chrome
ai/rockylinux-9-desktop
ai/ubuntu-desktop
......
列出特定镜像的所有 tag
[root@nexus ~]# nexus-cli image tags -name tools/nginx
Error parsing version2: "No Major.Minor.Patch elements found"
1.16
1.20.1
There are 2 images for tools/nginx
查看特定 tag 的信息
[root@nexus ~]# nexus-cli image info -name tools/nginx -tag 1.16
Image: tools/nginx:1.16
Size: 6645
Layers:sha256:54fec2fa59d0a0de9cd2dec9850b36c43de451f1fd1c0a5bf8f1cf26a61a5da4 27098254sha256:5546cfc927724eff7f5a134801904dee21064bd49912a7c4daa550175939cbce 23879166sha256:50f62e3cdaf71a6b4ba0cbe2115ce42d90cce8301cbf8220d2a99d19e0b85690 202
删除特定 tag 镜像
[root@nexus ~]# nexus-cli image delete -name tools/nginx -tag 1.16# 删除多个
nexus-cli image delete -name dockernamespace/yourimage -tag 1.16,1.20
在删除之前运行测试
nexus-cli image delete -name tools/nginx -keep 4 -dry-run
删除所有标签,但保留最近的4。注意,latest也算,被认为是“最近的”。
nexus-cli image delete -name dockernamespace/yourimage -keep 4
清理磁盘空间
创建两个Nexus Task 来清理物理空间。先运行 Purge unused docker manifests and images,再运行 Compact blob store,也可以直接手动执行清理。
如果没有这两个任务的可以直接创建
Compact blob store
Purge unused docker manifests and images
这篇关于nexus 清理 docker 镜像的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!