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

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

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

相关推荐
知已难寻15 小时前
Docker 入门:容器技术与 Docker 基础
java·运维·服务器·docker·云原生·容器
xbzb20 小时前
镜像到底存在哪:/var/lib/docker 的四级映射与 daemon.json 配置
docker·容器·json·镜像·daemon.json·四级
喵个咪1 天前
GoWind 拆解:全链 ID 类型体系——int64 定版与前端字符串化契约
前端·后端·go
喵个咪1 天前
GoWind CMS 拆解:发布审批——多级推进、逐级角色与全程留痕
前端·后端·go
喵个咪1 天前
GoWind Flow 拆解:一个 Go 工作流引擎与它的双模式设计器
前端·后端·go
喵个咪1 天前
GoWind CMS 拆解:搜索三板斧——高亮、联想、同义词
后端·搜索引擎·go
喵个咪1 天前
GoWind 拆解:AI Agent 编排引擎——波次并行、子图递归与人工审批
人工智能·后端·go
喵个咪1 天前
GoWind Admin 拆解:打印模板设计器——从画布到服务端 PDF 的完整打印链路
前端·后端·go
喵个咪1 天前
GoWind Admin 拆解:BI 大屏设计器——schema 即 JSON、resolver 注入与三张快照表的口径谱系
大数据·后端·go
方便面不加香菜1 天前
Docker Volume -- 管理卷Volume详解
运维·docker·容器