duanbiaoshu2021 2019-03-19 14:03
浏览 53
已采纳

在Go的私有注册表中检查docker映像是否存在

I'm wondering how I can check that a docker image exists in a private registry (in eu.gcr.io), without pulling it.

I have a service, written in golang, which needs to check for the existence of a docker image in order to validate a config file passed to it by a user.

Pulling the image using the go docker client, as shown here, works. However, I don't want to pull down images just to check they exist, as they can be large.

I've tried using Client.ImageSearch, but his just searches for public images. the cloud.google.com/go package also doesn't seem to have anything for dealing with the container registry.

There's possibly this and the crane tool it contains, but I'm really struggling to figure out how it works. The documentation is... not great.

I'd like the solution to be host agnostic, and the only option I have found is to simply make a http request and use the logic from this answer.

Are there any docker or other packages able to do this in a cleaner way?

  • 写回答

1条回答 默认 最新

  • dongzhuonao8429 2019-03-19 14:22
    关注

    Just realised the lib I've been using has an unhelpfully named client method DistributionInspect (link), which will just return the image digest and manifest, if it's found. so the image doesn't get pulled down.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?