Quickstart with gcloud command-line tool

This quickstart explains how to use the Container Builder API with the gcloud command-line tool to package a simple Node.js application as a Docker image and push it to Container Registry.

You can also complete Quickstart with curl. If you already have a Dockerfile to build, see Quickstart with a Dockerfile.

Before you begin

  1. Sign in to your Google account.

    If you don't already have one, sign up for a new account.

  2. In the Cloud Platform Console, go to the Manage resources page and select or create a new project.

    Go to the Manage resources page

  3. Enable billing for your project.

    Enable billing

  4. Enable the Container Builder API.

    Enable the API

  5. Install and initialize the Cloud SDK.

Log in to Google Cloud

  1. If you are not using Cloud Shell, authorize gcloud to access your project:

    gcloud auth login
  2. Configure your project for gcloud, where [PROJECT-ID] is your Cloud Platform project ID:

    gcloud config set project [PROJECT_ID]

    If you don't know your project ID, run the following command:

    gcloud projects list

Create a build request

Build requests are JSON or YAML documents which instruct Container Builder to perform tasks, and to package, build, and push Docker images, based on your specifications.

Build requests are composed of build steps, which are Docker containers that execute code on your behalf. Calling build steps is analogous to calling scripts or shell commands.

The Build API resource describes the build request model.

To create the build request, follow the steps below:


Create a file named cloudbuild.yaml with the following contents:

    - name: 'gcr.io/cloud-builders/docker'
      args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/cb-demo-img', '.' ]
    - 'gcr.io/$PROJECT_ID/cb-demo-img'


Create a file named request.json with the following contents:

      "steps": [
          "name": "gcr.io/cloud-builders/docker",
          "args": [
            "build", "-t", "gcr.io/$PROJECT_ID/cb-demo-img", "."
      "images": [

In this build request, Container Builder calls the docker build step with the arguments build -t gcr.io/$PROJECT_ID/cb-demo-img ..

The full name of the image to be built is gcr.io/$PROJECT_ID/cb-demo-img. Images pushed to Container Registry use the registry name format.

Submit the build request

To submit the build request, run the following command:


gcloud container builds submit --config cloudbuild.yaml gs://container-builder-examples/node-docker-example.tar.gz


gcloud container builds submit --config request.json gs://container-builder-examples/node-docker-example.tar.gz

The code source for the build is in a compressed tar archive, node-docker-example.tar.gz. The file is stored in a Cloud Storage bucket named container-builder-examples. Container Builder accesses Cloud Storage buckets via their URLs, which begin with gs://.

The gcloud container builds submit command:

  • initiates a build using the files stored in Cloud Storage as input
  • pushes the built image to Container Registry

The build might take several minutes to complete. As the build progresses, its output is displayed in your shell or terminal window. When the build is complete, you should see output similar to the following:

ID                                    CREATE_TIME                DURATION STATUS
$BUILD_ID                             2016-09-28T13:46:29+00:00  1M56S    SUCCESS

where $BUILD_ID is your build's unique identifier.

View build details and the build logs

To view the details about your build and view its logs, visit the following URL:



  • [BUILD-ID] is your build's unique identifier
  • [PROJECT-ID] is your Cloud Platform project ID

The URL opens Container Registry's build history menu in your Cloud Platform project.

Locate your Docker image

When you build a Docker image using Container Builder, your built image is stored in Container Registry, a private repository for Docker images.

To locate your built image, run the following command:

gcloud container images list

list displays all images stored in Container Registry.

You can also:

Clean up

To avoid incurring charges to your Google Cloud Platform account for the resources used in this quickstart:

Delete your Docker image

To delete your Docker image, run the following command:

gcloud container images delete [HOSTNAME]/[YOUR-PROJECT-ID]/[IMAGE]

where [HOSTNAME]/[YOUR-PROJECT-ID]/[IMAGE] is your image's registry name.

If you don't know your image's registry name, run the following command:

gcloud container images list

Delete your project

  1. Go to the Cloud Platform Console.
  2. Click the check box beside your project, then click Delete Project. This schedules the project for deletion.

What's next

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Container Builder