gcloud builds submit: Build with Cloud Build in CI
Send source to Cloud Build to build and (optionally) push a container image.
gcloud builds submit uploads your source and runs a build on Cloud Build, either from a cloudbuild.yaml config or as a single docker build via --tag. It is a common way to build images without a Docker daemon on the runner.
Common flags
SOURCE- directory or archive to build (positional, defaults to .)--tag=IMAGE- build a Dockerfile and push to this image tag--config=cloudbuild.yaml- run a multi-step build config--region=REGION- run the build in a specific region
Example in CI
Build and push an image straight from the Dockerfile.
shell
gcloud builds submit . \
--tag=us-central1-docker.pkg.dev/my-project/repo/app:${GITHUB_SHA} \
--region=us-central1Common errors in CI
- denied: Permission "storage.objects.create" - SA missing access to the Cloud Build staging bucket
- failed to build: ... Dockerfile not found - wrong SOURCE path or missing Dockerfile
- PERMISSION_DENIED: Cloud Build API has not been used - enable cloudbuild.googleapis.com
Key takeaways
- Builds container images on Cloud Build, no local Docker daemon required.
- Use --tag for simple builds, --config for multi-step pipelines.
- Enable the Cloud Build API and grant staging-bucket access to the SA.
Related guides
gcloud run deploy: Ship to Cloud Run in CIDeploy a container or source to Cloud Run from a pipeline: the flags you need, a CI example, and the deploy e…
gcloud auth configure-docker: Push Images in CIConfigure Docker to authenticate to Artifact Registry and GCR via gcloud: flags, a CI example, and the auth e…
gcloud functions deploy: Deploy Cloud Functions in CIDeploy a Cloud Function from a pipeline: runtime and trigger flags, a CI example, and the deployment errors t…