This page describes how to configure the container port, entrypoint command and arguments.
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.
Configuring the container port
Any configuration change leads to the creation of a new revision. Subsequent revisions will also automatically get this configuration setting unless you make explicit updates to change it.
The container should listen on the port defined by the PORT
environment variable
rather than a specific hardcoded port.
However, if this is not possible, you can configure on which port requests are
sent to the container:
Console
Click Create Service if you are configuring a new service you are deploying to. If you are configuring an existing service, click on the service, then click Edit and Deploy New Revision.
Under Advanced Settings, click Container.
Specify the port you want requests to be sent to, if not the default value of `8080`. This also sets the `PORT` environment variable.
Click Create or Deploy.
Command line
You can update a service's port configuration using the following command:
gcloud run services update SERVICE --port PORT
Replace
- SERVICE with the name of the service.
- PORT with the port to send requests to. Note that the
default port is
8080
.
You can also configure ports during deployment using the command:
gcloud run deploy --image IMAGE_URL --port PORT
Replace IMAGE_URL
with a reference to the container image, for
example, gcr.io/myproject/my-image:latest
.
YAML
You can download and view existing service configuration using the
gcloud run services describe --format export
command, which yields
cleaned results in YAML format. You can then modify the fields described below and
upload the modified YAML using the gcloud beta run services replace
command.
Make sure you only modify fields as documented.
To view and download the configuration:
gcloud run services describe SERVICE --format export > service.yaml
Update the
containerPort:
attribute:spec: containers: - image: IMAGE_URL ports: - containerPort: PORT
Replace
IMAGE_URL
with a reference to the container image, for example,gcr.io/myproject/my-image:latest
.- PORT with the port to send requests to.
Replace the service with its new configuration using the following command:
gcloud beta run services replace service.yaml
Configuring the container entrypoint command and arguments
Any configuration change leads to the creation of a new revision. Subsequent revisions will also automatically get this configuration setting unless you make explicit updates to change it.
You can set entrypoint command and arguments using the Cloud Console, the gcloud command line, or using a .yaml file when you create a new service or deploy a new revision:
Console
Click Create Service if you are configuring a new service you are deploying to. If you are configuring an existing service, click on the service, then click Edit and Deploy New Revision.
Under Advanced Settings, click Container.
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.
Click Create or Deploy.
Command line
You can update the start command and arguments of a given service by using the following command:
gcloud run services update SERVICE --command COMMAND --args ARG1,ARG-N
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, use a comma delimited list for more than one argument.
You can also specify entrypoint and arguments during deployment using the command:
gcloud run deploy --image IMAGE_URL --command COMMAND --args ARG1,ARG-N
Replace IMAGE_URL
with a reference to the container image, for
example, gcr.io/myproject/my-image:latest
.
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" \
--args "--gh-webhook-secret=XX" \
If your arguments use commas, refer to configuring environment variables for details on escaping those.
YAML
You can download and view existing service configuration using the
gcloud run services describe --format export
command, which yields
cleaned results in YAML format. You can then modify the fields described below and
upload the modified YAML using the gcloud beta run services replace
command.
Make sure you only modify fields as documented.
To view and download the configuration:
gcloud run services describe SERVICE --format export > service.yaml
Update the
command
andargs
attributes:spec: containers: - image: IMAGE_URL command: - COMMAND args: - "ARG1" - "ARG-N"
Replace
IMAGE_URL
with a reference to the container image, for example,gcr.io/myproject/my-image:latest
.- 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, use a comma delimited list for more than one argument.
Replace the service with its new configuration using the following command:
gcloud beta run services replace service.yaml