Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
You can configure Cloud Build to deploy a prebuilt image that is stored
in Artifact Registry to Cloud Run.
To deploy a prebuilt image:
Open a terminal window (if not already open).
Create a new directory named helloworld and navigate into it:
mkdir helloworld
cd helloworld
Create a file named cloudbuild.yaml with the following contents. This file is
the Cloud Build config file. It contains instructions for Cloud Build
to deploy the image named us-docker.pkg.dev/cloudrun/container/hello on the Cloud Run
service named cloudrunservice.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThis guide demonstrates how to use Cloud Build to deploy a containerized application image to Cloud Run.\u003c/p\u003e\n"],["\u003cp\u003eCloud Build requires specific permissions, including Cloud Run Admin, Storage Object User, and IAM Service Account User, which can be granted via \u003ccode\u003egcloud\u003c/code\u003e commands.\u003c/p\u003e\n"],["\u003cp\u003eA prebuilt image stored in Artifact Registry can be deployed to Cloud Run by creating a \u003ccode\u003ecloudbuild.yaml\u003c/code\u003e configuration file and running the \u003ccode\u003egcloud builds submit\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eThe deployed image can be accessed and run by navigating to the Cloud Run page in the Google Cloud console and clicking on the service URL.\u003c/p\u003e\n"],["\u003cp\u003eCloud Build supports deployment to platforms other than Cloud Run, such as App Engine, GKE, and Cloud Run Functions, and Cloud Deploy can be used for continuous delivery to Cloud Run.\u003c/p\u003e\n"]]],[],null,["# Quickstart: Deploy a containerized application to Cloud Run\n\nDeploy a containerized application to Cloud Run using Cloud Build\n=================================================================\n\nThis page shows you how to use Cloud Build to deploy a containerized application\nto Cloud Run.\n| **Note:** This quickstart shows you how to deploy an image to Cloud Run, but Cloud Build supports deployments on additional platforms such as App Engine, GKE, and Cloud Run functions. \n|\n| You can also use [Cloud Deploy](/deploy/docs/deploy-app-run) to set up a continuous-delivery pipeline to deploy to Cloud Run.\n\n*** ** * ** ***\n\nTo follow step-by-step guidance for this task directly in the\nCloud Shell Editor, click **Guide me**:\n\n[Guide me](https://console.cloud.google.com/freetrial?redirectPath=/getting-started?walkthrough_tutorial_id=cloud_build_deploy)\n\n*** ** * ** ***\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Build, Cloud Run, Artifact Registry, and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com,run.googleapis.com,artifactregistry.googleapis.com,compute.googleapis.com&redirect=https://cloud.google.com/cloud-build/docs/quickstart-deploy)\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Build, Cloud Run, Artifact Registry, and Compute Engine APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com,run.googleapis.com,artifactregistry.googleapis.com,compute.googleapis.com&redirect=https://cloud.google.com/cloud-build/docs/quickstart-deploy)\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n| If you've already installed Google Cloud CLI previously, make sure you have the\n| latest available version by running `gcloud components update`.\n\nGrant permissions\n-----------------\n\nCloud Build requires **Cloud Run Admin** and **IAM Service Account User**\npermissions before it can deploy an image to Cloud Run.\n\n1. Open a terminal window.\n\n2. Set environment variables to store your project ID and project number:\n\n PROJECT_ID=$(gcloud config list --format='value(core.project)')\n PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format='value(projectNumber)')\n\n3. Grant the **Cloud Run Admin** role to the\n [Cloud Build service account](/build/docs/cloud-build-service-account):\n\n gcloud projects add-iam-policy-binding $PROJECT_ID \\\n --member=serviceAccount:$(gcloud projects describe $PROJECT_ID \\\n --format=\"value(projectNumber)\")-compute@developer.gserviceaccount.com \\\n --role=roles/run.admin\n\n4. Grant the **Storage Object User** role to the Cloud Build service account:\n\n gcloud projects add-iam-policy-binding $PROJECT_ID \\\n --member=serviceAccount:$(gcloud projects describe $PROJECT_ID \\\n --format=\"value(projectNumber)\")-compute@developer.gserviceaccount.com \\\n --role=\"roles/storage.objectUser\"\n\n5. Grant the **IAM Service Account User** role to the Cloud Build service account for the **Cloud Run runtime service account**:\n\n gcloud iam service-accounts add-iam-policy-binding $(gcloud projects describe $PROJECT_ID \\\n --format=\"value(projectNumber)\")-compute@developer.gserviceaccount.com \\\n --member=serviceAccount:$(gcloud projects describe $PROJECT_ID \\\n --format=\"value(projectNumber)\")-compute@developer.gserviceaccount.com \\\n --role=\"roles/iam.serviceAccountUser\" \\\n --project=$PROJECT_ID\n\nDeploy a prebuilt image\n-----------------------\n\nYou can configure Cloud Build to deploy a prebuilt image that is stored\nin Artifact Registry to Cloud Run.\n\nTo deploy a prebuilt image:\n\n1. Open a terminal window (if not already open).\n\n2. Create a new directory named `helloworld` and navigate into it:\n\n mkdir helloworld\n cd helloworld\n\n3. Create a file named `cloudbuild.yaml` with the following contents. This file is\n the Cloud Build config file. It contains instructions for Cloud Build\n to deploy the image named `us-docker.pkg.dev/cloudrun/container/hello` on the Cloud Run\n service named `cloudrunservice`.\n\n steps:\n - name: 'gcr.io/cloud-builders/gcloud'\n script: |\n gcloud run deploy cloudrunservice --image us-docker.pkg.dev/cloudrun/container/hello --region us-central1 --platform managed --allow-unauthenticated\n\n4. Deploy the image by running the following command:\n\n gcloud builds submit --region=us-west2 --config cloudbuild.yaml\n\nWhen the build is complete, you will see an output similar to the following: \n\n DONE\n ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n ID CREATE_TIME DURATION SOURCE IMAGES STATUS\n 784653b2-f00e-4c4b-9f5f-96a5f115bef4 2020-01-23T14:53:13+00:00 23S gs://cloudrunqs-project_cloudbuild/source/1579791193.217726-ea20e1c787fb4784b19fb1273d032df2.tgz - SUCCESS\n\nYou've just deployed the image `hello` to Cloud Run.\n\nRun the deployed image\n----------------------\n\n1. Open the Cloud Run page in the Google Cloud console:\n\n [Open the Cloud Run page](https://console.cloud.google.com/run)\n2. Select your project and click **Open**.\n\n You will see the **Cloud Run Services** page.\n3. In the table, locate the row with the name **cloudrunservice** , and click\n **cloudrunservice**.\n\n The **Service details** page for **cloudrunservice** is displayed.\n4. To run the image that you deployed on **cloudrunservice**, click the URL:\n\nWhat's next\n-----------\n\n- [Learn how to build using Cloud Build](https://cloud.google.com/cloud-build/docs/quickstart-build).\n- [Learn how to create a basic build config file](https://cloud.google.com/cloud-build/docs/configuring-builds/create-basic-configuration).\n- [Learn how to view build results](https://cloud.google.com/cloud-build/docs/view-build-results).\n- [Learn about more ways to deploy to Cloud Run](https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-cloud-run).\n- [Learn how to deploy to Google Kubernetes Engine](https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-gke).\n- [Learn more about DevOps resources](https://cloud.google.com/devops).\n- [Explore the DevOps research program](https://www.devops-research.com/research.html)."]]