golang 上传离线tar/gz镜像文件至Harbor仓库

hello,今天和大家分享个小工具 (^_^)

在实际业务场景中,通常我们提交docker镜像,通过 docker push 命令来发布至远程仓库中,但这种方式需要本地环境中存在要发布的镜像文件,比如 alpine:3.8 我要提交 docker push 仓库名称/alpine:3.8

如果有较多镜像已经通过 docker save 方式另存到了另外的文件系统中, 我们要把这些镜像发布到远程仓库中,那发布的过程是非常的繁琐。

针对这个业务场景,Fork了 silenceper/docker-tar-push 项目,二次研发后将我们业务需求实现。 有这种需求的小伙伴,欢迎用起来呀~~

docker-tar-push github仓库地址:github.com/hltfaith/do...

docker-tar-push命令下载地址:github.com/hltfaith/do...

功能

  • 支持gz格式的image
  • 支持对image增加前缀repo
  • 支持上传harbor

使用

shell 复制代码
$ docker-tar-push -h
push your docker tar archive image without docker.

Usage:
  docker-tar-push [flags]

Flags:
  -h, --help                  help for docker-tar-push
      --image-prefix string   add image repo prefix
      --log-level int         log-level, 0:Fatal,1:Error,2:Warn,3:Info,4:Debug (default 3)
      --password string       registry auth password
      --registry string       registry url
      --skip-ssl-verify       skip ssl verify
      --username string       registry auth username

用法一

shell 复制代码
docker-tar-push alpine:latest --registry=http://localhost:5000

用法二

例如将 docker save python:3.0 > python-3.10.tar 镜像文件推送harbor仓库, 这时需要存放至 harbor仓库 library 项目中,使用下面参数 --image-prefix=library/ 即可。

shell 复制代码
docker-tar-push /镜像目录路径 --registry=http://harbor.harbor.svc --username=admin --password=Harbor12345 --image-prefix=library/

当我们从仓库下载镜像时,它的完整名称为: docker pull harbor.harbor.svc/library/python:3.0

编译

shell 复制代码
go build -o bin/docker-tar-push cmd/docker-tar-push/main.go

技术文章持续更新,请大家多多关注呀~~

搜索微信公众号,关注我【 帽儿山的枪手 】

相关推荐
虎头金猫1 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
分布式存储与RustFS1 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
alsmile1 天前
Node-RED 之外,国产规则引擎的新方案:基于标准语法,Go 先行实现
后端·开源·go
玉&心2 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing2 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
赵文宇(温玉)2 天前
CoreDNS的hosts插件的缺行配置导致k8s集群异常
容器·kubernetes·rancher
茉莉玫瑰花茶2 天前
GO [ 变量 ]
go
guo_wen_qiang2 天前
上传本地镜像到harbor中
docker·容器·持续部署
羑悻的小杀马特2 天前
Dockerfile 全景指南:从入门编写dockerfile到生产环境镜像优化实战,一步步带你从啃透制作指令到镜像制作落地!
docker·dockerfile·镜像制作
lpfasd1232 天前
展厅中控总体架构
go·串口·中控