Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
Your team is setting up a CI/CD pipeline for a Python web service deployed to Cloud Run using Terraform. Because Terraform references a container image URL in Artifact Registry, you must decouple the image build from deployment while meeting these requirements:
Dockerfile maintenance by using automated language runtime detection and dependency installation from requirements.txt.gunicorn as the container startup process.Which configuration and build command should you use?
Dockerfile from the repository, declare the gunicorn startup command in a Procfile, and run gcloud builds submit --tag LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/IMAGE_NAME.gcloud builds submit --tag doesThe gcloud builds submit --tag command submits source code to Cloud Build to execute a standard Docker build and push the resulting image to Artifact Registry. Under the hood, --tag instructs Cloud Build to generate an implicit build step that runs docker build against the uploaded source directory.
Dockerfile: Unlike --pack, the --tag flag does not invoke Google Cloud Buildpacks. It expects a Dockerfile to be present in the root of the source directory (unless a cloudbuild.yaml configuration file is supplied).Dockerfile or a build configuration file, the gcloud builds submit --tag command fails immediately rather than inspecting requirements.txt or reading the Procfile.Dockerfile instructions such as FROM, COPY, RUN, and CMD.Procfile: Standard docker build does not parse a Procfile unless a Dockerfile manually copies and invokes a process runner.Your team wanted to maintain a custom Dockerfile in the repository—for instance, to install specialized system binaries or run custom multi-stage compilation steps—and simply needed Cloud Build to execute docker build remotely.
A common misconception is that --tag automatically falls back to Buildpacks when a Dockerfile is missing. In Cloud Build, you must explicitly pass --pack image=... (or define a pack step in cloudbuild.yaml) to use Buildpacks.
Dockerfile from the repository, declare the gunicorn startup command in a Procfile, and run gcloud builds submit --pack image=LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/IMAGE_NAME.--pack areGoogle Cloud Buildpacks are an open-source implementation of the Cloud Native Buildpacks (CNB) specification that transform application source code into production-ready container images without a manual Dockerfile. When invoked remotely through Cloud Build using the --pack flag, Cloud Build executes a builder image in an ephemeral virtual machine to analyze the repository, create a build plan, and push the resulting container image directly to Artifact Registry.
requirements.txt or pyproject.toml), automatically identifies Python as the language runtime, and invokes the Python and pip buildpacks to fetch and install dependencies onto a Google-managed base image.Procfile explicitly defines the gunicorn web process to invoke when the container starts.gcloud builds submit --pack runs the containerization pipeline inside an isolated, temporary Cloud Build environment and stores the finished image at the specified Artifact Registry URI for Terraform to reference.Using --pack with a Procfile and no Dockerfile combines automated language detection and dependency resolution with remote, auditable Cloud Build execution, cleanly separating container creation from Terraform-managed Cloud Run deployment.
Dockerfile with only the gunicorn CMD instruction, and run gcloud run deploy --source . so Buildpacks detects Python and installs requirements.txt before deployment.gcloud run deploy --source with a Dockerfile doesThe gcloud run deploy --source . command is a convenience workflow that uploads local source code, triggers Cloud Build to build a container image, pushes it to Artifact Registry, and immediately deploys a new revision to Cloud Run. When a Dockerfile is present in the source directory, Cloud Build uses that Dockerfile to construct the image.
Dockerfile exists in the source directory, Buildpacks are not invoked. A minimal Dockerfile containing only CMD will fail or omit Python and requirements.txt because Buildpacks will not run to detect the runtime or install dependencies.gcloud run deploy --source directly provisions or updates a Cloud Run service rather than only producing an image URL in Artifact Registry for Terraform to manage.Dockerfile with Buildpacks runtime detection in a single source build.--source (without a Dockerfile), it always uses the default gcr.io/buildpacks/builder:latest image.You wanted a single-command developer workflow to both build and deploy a service directly to Cloud Run without Terraform, and you either removed the Dockerfile (using a Procfile instead) or wrote a complete Dockerfile.
Understanding Dockerfile precedence is critical when adopting Buildpacks: leaving an unused or partial Dockerfile in a repository silently disables Buildpacks' automatic language detection.
Dockerfile from the repository, specify the gunicorn entrypoint in project.toml, and run pack build --builder=gcr.io/buildpacks/builder --publish LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/IMAGE_NAME.pack CLI and project.toml doThe pack CLI is the official Cloud Native Buildpacks tool for building container images locally on a developer workstation or CI runner using a local Docker daemon. The project.toml file is a buildpacks project descriptor used to configure build-time metadata, such as pinning a specific builder image or setting build environment variables.
pack build --publish performs containerization inside the local Docker engine rather than remotely in Cloud Build's ephemeral VM environment. This misses Cloud Build's isolated build infrastructure and automated SLSA Level 3 build provenance.project.toml for process startup: In Google Cloud Buildpacks for Python, a Procfile—not project.toml—is required to declare the web startup process (gunicorn). While project.toml can set environment variables like GOOGLE_FUNCTION_TARGET for Cloud Functions or specify a [build] builder URL, it does not replace a Procfile for general Python web server commands.pack CLI depends on Docker Community Edition being installed and running on the host machine.You wanted to prototype and test a Buildpacks container image locally on a workstation with Docker installed before deploying, and you used a Procfile for the gunicorn startup command.
While Cloud Build internally uses pack when you pass --pack or configure a pack step in cloudbuild.yaml, running pack build directly bypasses Cloud Build's managed execution environment.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated