2

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.

5
  • 1
    From this documentation limitation of Container-Optimized OS Container-Optimized OS is locked down, this means that it cannot be modified by startup scripts. Commented Nov 10, 2022 at 23:11
  • You can create a COS instance and either specify a cloud-init or a startup script. Commented Nov 11, 2022 at 0:17
  • Don't use gcloud compute instances create-with-container just gcloud compute instances create using COS and --metadata-from-file or --metadata=startup-script= respectively. Commented Nov 11, 2022 at 0:17
  • @DazWilkin I'm baffled that I didn't think of that, haha. Worked like charm. Thanks! If you want to copy your comment to an answer, I can select it as the solution :). Cheers again. Commented Nov 13, 2022 at 17:40
  • You're welcome! I'm pleased to hear it. We all have occasions where we get stuck on a path like this. This is why Rubber Duck Dedbugging really does work and why "I went for a smoke and realized the solution" also works. Commented Nov 13, 2022 at 17:53

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.