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.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eBuilders are versioned images containing necessary components to create a runnable container, using a specific OS distribution and supporting various programming language versions.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify a builder version using the \u003ccode\u003e--builder\u003c/code\u003e flag with the \u003ccode\u003epack\u003c/code\u003e command or through a \u003ccode\u003eproject.toml\u003c/code\u003e file for local builds.\u003c/p\u003e\n"],["\u003cp\u003eFor remote builds using Cloud Build, you can specify a builder by including the \u003ccode\u003e--pack\u003c/code\u003e flag in the \u003ccode\u003egcloud builds submit\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eWhen using Cloud Run to deploy from source, you can define the builder to be used by populating a \u003ccode\u003eproject.toml\u003c/code\u003e file with the specific builder URL.\u003c/p\u003e\n"],["\u003cp\u003eBoth local and remote builds require specific tools, such as the Pack CLI, Docker, Git, and gcloud CLI, installed and configured properly.\u003c/p\u003e\n"]]],[],null,["# Use a specific builder\n\n[Builders](/docs/buildpacks/builders) are versioned images that contain all the\ncomponents necessary to create a runnable container. Each builder uses a specific\nOS distribution as the base image, like Ubuntu 22, and supports multiple\nprogramming language versions.\n\nYou might need to customize the version of builder if you require:\n\n- A OS-specific dependency that is available only in a specific builder version.\n- A specific version of programing language that is available only in a specific builder version.\n\nLocal builds\n------------\n\nFor local builds, you must have the Pack CLI and Docker installed.\n\n### Before you begin\n\n1. Install [Docker Community Edition (CE)](https://docs.docker.com/engine/installation/) on your workstation. Docker is used by `pack` as an OCI image builder.\n2. Install [Pack CLI](https://buildpacks.io/docs/tools/pack/).\n3. Install the [Git source control](https://git-scm.com/downloads) tool to fetch the sample application from GitHub.\n\n### Specifying the builder version with `pack`\n\nYou can append the `--builder` flag to the pack command to specify the version\nof builder you want to use: \n\n```sh\npack build SERVICE_IMAGE_NAME --builder=BUILDER_IMAGE_URL\n```\n\nReplace:\n\n- `BUILDER_IMAGE_URL` with the URL of the builder. Example: `gcr.io/buildpacks/builder:google-22`\n- `SERVICE_IMAGE_NAME` with the name that you choose for your application image.\n\nTo learn more about the `pack` command, see the\n[CLI documentation](https://buildpacks.io/docs/tools/pack/cli/pack_build/)\n\n### Specifying the builder version with `project.toml`\n\nYou can use a buildpacks [project descriptor](https://buildpacks.io/docs/app-developer-guide/using-project-descriptor/)\n(`project.toml`) to set the builder when building with `pack`\n\n1. In your application root directory, create a file named `project.toml` with the following configuration: \n\n ```sh\n [build]\n builder = \"BUILDER_IMAGE_URL\"\n ```\n2. Build your application by running the \\`pack\\` command: \n\n ```sh\n pack build SERVICE_IMAGE_NAME\n ```\n\nReplace:\n\n- `BUILDER_IMAGE_URL` with the URL of the builder, for example, `gcr.io/buildpacks/builder:google-22`\n- `SERVICE_IMAGE_NAME` with the name that you choose for your application image.\n\nRemote builds\n-------------\n\nYou can use a specific builder with Cloud Build by appending the `--pack`\nflag when submitting your project.\n\n### Before you begin\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 and Artifact Registry APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com, artifactregistry.googleapis.com&redirect=https://cloud.google.com/docs/buildpacks/build-application)\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 and Artifact Registry APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com, artifactregistry.googleapis.com&redirect=https://cloud.google.com/docs/buildpacks/build-application)\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`.\n1. Ensure that your Google Cloud project has access to a container image repository. To configure access to a\n [Docker repository in\n Artifact Registry](/artifact-registry/docs/docker/store-docker-container-images):\n\n 1. Create a new Docker repository in the same location of your Google Cloud project. \n\n ```bash\n gcloud artifacts repositories create REPO_NAME \\\n --repository-format=docker \\\n --location=REGION --description=\"\u003cvar translate=\"no\"\u003eDESCRIPTION\u003c/var\u003e\"\n ```\n Replace:\n - `REPO_NAME` with the name that you choose for your Docker repository.\n - `REGION` with the [location](/artifact-registry/docs/repositories/repo-locations) in or nearest to the location of your Google Cloud project.\n - `DESCRIPTION` with a description of your choice.\n\n For example, to create a `docker` repository in\n `us-west2` with the description \"Docker repository\", you run: \n\n ```bash\n gcloud artifacts repositories create buildpacks-docker-repo --repository-format=docker \\\n --location=us-west2 --description=\"Docker repository\"\n ```\n 2. Verify that your repository was created: \n\n ```bash\n gcloud artifacts repositories list\n ```\n\n You should see name that you choose for your Docker repository in the list.\n\n### Build the application using a specific builder\n\n1. Use `gcloud` to submit the application source code to Cloud Build: \n\n ```sh\n gcloud builds submit --pack builder=BUILDER_IMAGE_URL,image=LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/SERVICE_IMAGE_NAME\n ```\n\n Replace:\n - `BUILDER_IMAGE_URL` with the url of the builder. Example: `gcr.io/buildpacks/builder:google-22`\n - `LOCATION` with the region name of your container repository. Example: **us-west2**`-docker.pkg.dev`\n - `PROJECT_ID` with the ID of your Google Cloud project.\n - `REPO_NAME` with the name of your Docker repository.\n - `SERVICE_IMAGE_NAME` with the name of your container image that you created.\n\n \u003cbr /\u003e\n\n To learn more about the `submit` command, see the\n [Cloud Build\n documentation](/sdk/gcloud/reference/builds/submit).\n2. Verify that the sample application was successfully published to \u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e: \n\n ```bash\n gcloud artifacts docker images list LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME\n ```\n\n Replace:\n - `LOCATION` with the region name of your container repository. Example: **us-west2**`-docker.pkg.dev`\n - `PROJECT_ID` with the ID of your Google Cloud project.\n - `REPO_NAME` with the name of your Docker repository.\n\nDeploy from Source with Cloud Run\n---------------------------------\n\nYou can use a buildpacks [project descriptor](https://buildpacks.io/docs/app-developer-guide/using-project-descriptor/)\nfile e.g. `project.toml` to set the builder when [deploying from source with Cloud Run](/run/docs/deploying-source-code)\n\n1. Initialize a `project.toml` file at the root of your application directory and paste the following configuration into it: \n\n ```sh\n [build]\n builder = \"BUILDER_IMAGE_URL\"\n ```\n2. Deploy your application from source \n\n ```sh\n gcloud run deploy --source . SERVICE_IMAGE_NAME\n ```\n\nReplace:\n\n- `BUILDER_IMAGE_URL` with the URL of the builder. Example: `gcr.io/buildpacks/builder:google-22`\n- `SERVICE_IMAGE_NAME` with the name of your container image that you created."]]