1

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?

Jonas D
  • 258
  • 5
  • 14

1 Answers1

3

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.

Jonas D
  • 258
  • 5
  • 14
  • Can you share a snippet of you populated the 3 arguments? – Kevin Wang Jun 01 '22 at 05:55
  • It's been a while aha but for Google Cloud Regstry something like `ctx, cancel := context.Background()\n inspect, error := cli.DistributionInspect(ctx, 'your.registry/image/name:tag', '')` – Jonas D Jun 10 '22 at 10:46