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 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝