Search code examples
dockergoogle-cloud-platformgoogle-compute-enginegoogle-container-optimized-os

Disable Container Auto Launch on Google Container Optimized OS on GCP


According to Creating and configuring instances and my own testing, the Google Container Optimized OS launches the specified container on instance startup.

However, I'd like to execute my own startup script which would include running the container. Is there any way to prevent this default behaviour of automatically running the container on startup?

Specifiying a custom startup script for the instance doesn't seem to prevent the default behaviour.


Solution

  • You can create a COS instance and either specify a cloud-init or a startup script.

    Then use gcloud compute instances create (rather than gcloud compute instances create-with-container) and --metadata-from-file or --metadata=startup-script= respectively.