<p>I found that <strong>startup scripts</strong> can be added to <strong>Google compute instances</strong> using either the <strong>console</strong> or <strong>cli(gcloud).</strong> I want to add the <strong>startup scripts</strong> to <strong>google container engine.</strong> </p>

<p>The <strong>goal</strong> is to <strong>notify</strong> me when the google container engine has changed its state to <strong>Running</strong>. I though one efficient way is to use startup scripts in container engine, as these scripts will only be executed when the container's status is changed to running.</p>

<p>Any idea how to add startup scripts to container engine or any other way of notifying when the container's status changes to running.</p>

<p>First of all your question is fairly complicated. The concept of startup scripts do not belong to the containers world. <strong>As far as I know you can't add startup scripts in Google Container Engine</strong>. This is because Container Engine instances are immutable (e.g. you can't or you are not supposed to modify the operating system, you should just run containers).</p>

<p>If you're trying to run scripts when a container starts/stops you need to forget about startup scripts concept in the Compute Engine world. You can use <strong>container lifecycle hooks</strong> in Kubernetes (the orchestrator running in Container Engine). </p>

<p>Here's documentation and tutorial about it: 
<a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/</a>
<a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/</a></p>
