Configure containers

This page describes how to configure the entrypoint command and arguments for Cloud Run jobs.

When Cloud Run starts a container, it runs the image's default entrypoint command and default command arguments. If you want to override the image's default entrypoint and command arguments, you can use the command and args fields in the container configuration. The command field specifies the actual command run by the container. The args field specifies the arguments passed to that command.

Required roles

To get the permissions that you need to configure Cloud Run jobs, ask your administrator to grant you the following IAM roles:

For a list of IAM roles and permissions that are associated with Cloud Run, see Cloud Run IAM roles and Cloud Run IAM permissions. If your Cloud Run job interfaces with Google Cloud APIs, such as Cloud Client Libraries, see the service identity configuration guide. For more information about granting roles, see deployment permissions and manage access.

Configure entrypoint and arguments

To configure command entrypoint and arguments for jobs:

Console

  1. In the Google Cloud console, go to the Cloud Run jobs page:

    Go to Cloud Run

  2. If you are configuring a new job, click the Jobs tab and fill out the initial job settings page as desired. If you are configuring an existing job, click the job, then click Edit.

  3. Click Container, variables and secrets, connections, security to expand the job properties page.

  4. Click the General tab.

    image

    • Specify the command you want the container to run, if not the command defined in your container, and optionally specify the arguments to the entrypoint command.
  5. Click Create or Update.

Command line

  1. To set the start command and arguments for a new job:

    gcloud run jobs create JOB_NAME --image IMAGE_URL --command COMMAND --args ARG1,ARG-N

    Replace

    • JOB_NAME with the name of your job.
    • COMMAND with the command that the container is to start up with if you are not using the default command.
    • ARG1 with the argument you are sending to the container command, or use a comma delimited list for more than one argument.
    • Replace IMAGE_URL with a reference to the container image, for example, us-docker.pkg.dev/cloudrun/container/job:latest.

To update command and args for an existing job:

gcloud run jobs update JOB_NAME --command COMMAND --args ARG1,ARG-N 

YAML

Download and view existing job configuration using the gcloud run jobs describe --format export command, which yields cleaned results in YAML format. Then modify the fields described below and upload the modified YAML using the gcloud run jobs replace command. Make sure you only modify fields as documented.

  1. To view and download the configuration:

    gcloud run jobs describe JOB_NAME --format export > job.yaml
  2. Update the args: and command attributes:

    apiVersion: run.googleapis.com/v1
    kind: Job
    metadata:
      name: JOB_NAME
    spec:
      template:
        spec:
          template:
            spec:
              containers:
              - args:
                - 'ARG1'
                - 'ARG-N'
                command:
                - COMMAND
                image: IMAGE

    Replace

    • COMMAND with the command that the container is to start up with if you are not using the default command.
    • ARG1 with the argument you are sending to the container command. Optionally specify additional arguments each in a separate line.

    You can also specify more configuration such as environment variables or memory limits.

  3. Update the existing job configuration:

    gcloud run jobs replace job.yaml

To clear any entrypoint commands and arguments you have set (restore to container defaults), supply empty strings as follows:

gcloud run jobs update JOB_NAME --command "" --args "" 

Use equals signs or commas in arguments

If you use equal signs in your arguments, supply these using the following format:

gcloud run deploy  \
  --args="--repo-allowlist=github.com/example/example_demo"

If your arguments use commas, refer to configuring environment variables for details on escaping those.

View container settings

To view the current container settings for your Cloud Run job:

Console

  1. In the Google Cloud console, go to the Cloud Run jobs page:

    Go to Cloud Run jobs

  2. Click the job you are interested in to open the Job details page.

  3. Click the Configuration tab.

  4. Locate the container setting in the configuration details.

Command line

  1. Use the following command:

    gcloud run jobs describe JOB_NAME
  2. Locate the container setting in the returned configuration.