Google Cloud Professional Cloud Developer — Question 337
You are deploying a containerized application to GKE. You have set up a build pipeline by using Cloud Build that builds a Java application and pushes the application container image to Artifact Registry. Your build pipeline executes multiple sequential steps that reference Docker container images with the same layers.
You notice that the Cloud Build pipeline runs are taking longer than expected to complete. How should you optimize the Docker image build process?
Answer options
- A. Add the --squash parameter to the Docker build steps to combine newly built layers into a single layer.
- B. Configure Cloud Build to use a private pool in your VPC for pipeline executions.
- C. Specify the cached image by adding the --cache-from argument in your build config file with the image as a cache source.
- D. Store container artifacts on Cloud Storage. Configure Cloud CDN on the Cloud Storage bucket to enable caching on edge locations.
Correct answer: C
Explanation
The correct answer is C because using the --cache-from argument allows the build process to leverage existing image layers, speeding up the build time significantly. Option A, while beneficial for reducing image size, does not directly address the speed of the build process. Option B may improve resource allocation but does not inherently optimize the image build time. Option D shifts the artifact storage but does not enhance the build efficiency itself.