Deploy services using Compose Stay organized with collections Save and categorize content based on your preferences.
Preview — Cloud Run Compose deploy
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
This page describes how to deploy services to Cloud Run using a filebased on theCompose Specification.
You can deploy to Cloud Run with a Compose file in the followingways:
Using Compose to deploy to Cloud Run is ideal for development andsimplifies the transition from your local environment to a cloud environment. It lets youmaintain a consistent configuration format for both your local and deployedapplications.
For managing production environments in an infrastructure-as-code (IaC)environment, we recommend usingTerraform.
Limitations
- Compose deployment deploys a single Cloud Run service withmultiple containers.
- Compose deployment translates only a subset ofsupported Cloud Run features.
- Services created using Compose are set by default to1 maximum instances.
- While it simplifies deployment, Cloud Run Compose deployisn't a replacement for a comprehensive infrastructure-as-code strategy forproduction environments.
Deploy services from container images with Compose
Define your services in acompose.yaml file and deploy them from existingcontainer images. For more information, seeDeploy container images.
Example: Single-service application
The following example shows acompose.yaml file for a web service that uses aprebuilt container image.
services:web:image:us-docker.pkg.dev/cloudrun/container/helloports:-"8080:8080"Deploy the services
To deploy the services, run the
gcloud beta run compose upcommand:gcloud beta run compose up compose.yamlRespond
yto any prompts to install required components or to enable APIs.Optional:Make your service public if you want to allow unauthenticated access to the service.
After deployment, the Cloud Run service URL is displayed. Copythis URL and paste it into your browser to view the running container. You candisable the default authentication from the Google Cloud console.
Deploy from source with Compose
Define your services in acompose.yaml file and deploy them by building fromsource code. For more information, seeDeploy services from source code.
Example: Single-service application
The following example shows acompose.yaml file for a web service that buildsfrom source in the current directory.
services:web:build:.ports:-"8080:8080"Deploy the services
In your project directory, create a
compose.yamlfile with yourservice definitions.To deploy the services, run the
gcloud beta run compose upcommand:gcloud beta run compose up compose.yamlRespond
yto any prompts to install required components or to enableAPIs.Optional:Make your service publicif you want to allow unauthenticated access to the service.
After deployment, the Cloud Run service URL is displayed. Copythis URL and paste it into your browser to view the running container. You candisable the default authentication from the Google Cloud console.
Supported features
When you deploy using acompose.yaml file, Cloud Run canautomatically provision other Google Cloud resources as defined in yourCompose file. If resources are required, Cloud Run prompts youfor consent before creating them.
Cloud Run supports the following subset of Compose features:
| Compose field | Cloud Run mapping & description |
|---|---|
services | Services map to individual containers in the deployedCloud Run service. |
volumes | Partially supported. Translates |
secrets | Supported. Using Secret Manager. |
configs | Supported. Using Cloud Storage. |
build | Cloud Build builds the container using the build context, tagging andpushing to the |
image | Deploys a prebuilt container image from a supported registry. Use if youhave a prebuilt image. Only supports Docker Hub and Artifact Registry images. Forcustom images, you can push images to Artifact Registry and use them. |
ports | A list of port mappings, such as |
expose | A list of ports to expose but not publish, such as |
depends_on | Defines the container startup order. This ensures that any |
cpu_count /cpus | A hint used to set Cloud Run CPU and memory limits,automatically allocating resources according to the following logic:
|
container_name | Sets the container's name for dependency resolution, defaulting to theservice name if not specified. |
environment | Passes environment variables to the corresponding container inCloud Run. |
command | Overrides the container's default command, declared by the container, bymapping to the |
entrypoint | Supported. |
env_file | Supported. |
x-google-cloudrun:ingress-container | (Extension) Add this Google-specific extension to a service and set to |
x-google-cloudrun:volume-type: in-memory | (Extension) Add this Google-specific extension to a volume and set to |
Secrets mapped to Secret Manager
If yourcompose.yaml file definessecrets, the gcloud CLIprovisions Secret Manager secrets to store this data.
Volumes and configs mapped to Cloud Storage
If yourcompose.yaml file defines top-levelvolumes orconfigs, thegcloud CLI provisions a Cloud Storage bucket to manage thisdata. A single bucket is created per deployment, using folders to separatevolumes and configs.
- Named volumes: An empty folder corresponding to the volume name iscreated in the bucket.
- Bind mounts: For bind mounts, Cloud Run uploads thecontents of the local source directory to a folder in the bucket prior todeployment.
- Configs: For each config defined with a
file:source, Cloud Runuploads the contents of the local file to a folder in the bucket.
Required roles
During deployment, Cloud Run automatically grants the serviceidentity of the deployed service the necessary roles to access provisionedresources:
- Cloud Storage Bucket:
roles/storage.objectUser - Secret Manager Secrets:
roles/secretmanager.secretAccessor
Communication between containers of the same instance
Cloud Run adds an entry to the/etc/hosts file in eachcontainer. This entry maps the service names from yourcompose.yaml file totheir internal IP addresses, which lets services communicate with each otherusing their service names.
What's next
- Learn more aboutmanaging services.
- Learn aboutsetting up authentication.
- Learn how tomanage secrets.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.