Difference between using and not using the 'images' attribute in .cloudyaml (for pushing to artifact registry)

56 Views Asked by At

I am reading the google cloud documentation and they have countless examples of using the docker build cloud-builder configuration.

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/myproject/myimage', '.']
images: ['gcr.io/myproject/myimage']

My question is, what is the difference between using and not using the images attribute? Does the images attribute signify that artifact registry will update the image. If I do not use the image attribute, what happens?

Thanks in advance.

Update: I think the documentation says if you do not add the images attribute the build fails, however there are countless examples in the documentation of the images attribute not being there (which is why I am curious about the matter).

Here is the page I am referring to. https://cloud.google.com/build/docs/build-config-file-schema

1

There are 1 best solutions below

2
guillaume blaquiere On

If you use the images attribute, and you don't push explicitly the image to the Artifact Registry, it's done automatically for you.

If you don't mention the images attributes and you push explicitly the image to Artifact Registry, no problem, your image is stored

However, ff you don't use the images attribute, and you don't push explicitly the image to the Artifact Registry, the image is "lost".

Losing an image is not a fatality!! It could be a transient image, cache, working and trashable image,...

I personally prefer to explicitly push the image (clearer for all the users, even those who don't handle the mysterious tricks of Cloud Build!), but it's only my opinion