Cloud Run instance lifecycle

A Cloud Run instance is a single, individually manageable compute resource that runs continuously. Unlike a Cloud Run service that scales horizontally based on incoming traffic, or a job that executes defined tasks and exits, a Cloud Run instance acts as a lightweight serverless virtual machine (VM), giving you direct control over individual lifecycle states, stable ingress URLs, and continuous compute budgets.

For more details on Cloud Run instances, see the product overview and Cloud Run resource comparison.

Cloud Run instance lifecycle

Like a VM, a Cloud Run instance moves through distinct lifecycle states and is managed through explicit, individual operations. Unlike a VM, you let Cloud Run handle the underlying compute infrastructure, host operating system, and network provisioning, retaining full Serverless ease-of-use.

The following diagram illustrates these lifecycle transitions:

Cloud Run instances lifecycle.
Figure 1.The different states of Cloud Run instances.

Lifecycle policies and restart conditions

You can define restart rules for each instance to handle process crashes and exit statements using the restartPolicy attribute:

  • on-failure (default): Restarts the container if its primary processes exit with a non-zero code, or if the container encounters system-level infrastructure failures.
  • always: Automatically restarts the container regardless of its exit status, including a clean exit code of 0.
  • never: Does not restart the container, immediately transitioning the instance to a STOPPED or FAILED state upon process termination.

If the restart policy is enabled, Cloud Run attempts to restart a failing instance up to 3 times sequentially. If the instance continues to fail, it transitions to the FAILED status.

What's next