Thank you for taking the time to read this.
We have a build trigger connected to our bitbucket repo that creates a docker container of our server and stores it as an image in the Container Registry on the Google Cloud Console.
We also have a Virtual Machine instance created under the Compute Engine that references this image. In general, all of this works fine. We are able to run our application as a docker container on this VM. We can connect to it remotely no problem.
In order to help streamline our process, we wanted the build trigger to force the VM to reset so that it would always be running the most up to date version of the docker container.
We did this by creating a Cloud Function. On the Topic:cloud-builds, we trigger a python script that resets our VM instance. We also know this works as whenever a build is completed we can see the VM reset within the VM logs.
The problem is that for some reason it does not always pick up the latest image. In fact, sometimes doing a manual reset on the VM does not do it. A number of resets (2 to 3) are required before the new container image shows up.
Is there something wrong with our approach for trying to do this? Or is there a certain amount of time (a minute or so) that has to pass before the new container image is available to be used within a VM instance?
Thank you again.