GCP Associate Cloud Engineer Practice Question 85: Cloud Run Deploy Source Build

Google Cloud Associate Cloud Engineer · Test 9 · question 5 of 10

Cloud Runmedium

A developer has application source code in a local directory but has not written a Dockerfile and does not want to manually build or push a container image before deploying. They want a single gcloud command that builds a container image from the source and deploys it to Cloud Run. Which command accomplishes this?

Select one answer
Show answer and explanation

Answer:

  • B. gcloud run deploy SERVICE --source=.

gcloud run deploy --source packages the local source directory, sends it to Cloud Build, which detects a Dockerfile or uses Google Cloud's buildpacks to build a container image automatically, pushes it to Artifact Registry, and deploys the resulting image to Cloud Run, all from one command with no Dockerfile required.

Option A requires an image that already exists in a registry; nothing here builds it, so the deploy would fail if the image has not been pushed yet. Option C does build an image with Cloud Build, but it stops there and requires a separate manual step to actually create or update the Cloud Run service, which is more work than the single --source flag. Option D deploys to App Engine, a different compute product with its own deployment model, not Cloud Run.

Reference: Deploying from source code

Practice Test 9 ›

Study guides for Google Cloud Associate Cloud Engineer