Q60 — AWS DOP-C02 Ch.1
Question 60 of 100 | ← Chapter 1
A DevOps engineer frequently uses AWS CodeBuild to build software packages from source code. CodeBuild projects build Docker images, which developers reuse across multiple builds. The DevOps engineer wants to improve build performance and optimize cost. Which solution meets these requirements?
- A. Store Docker images in an Amazon Elastic Container Registry (Amazon ECR) repository. Enable local Docker layer caching for CodeBuild. ✓
- B. Cache Docker images in an Amazon S3 bucket accessible across multiple build hosts. Use S3 lifecycle policies to invalidate the cache.
- C. Store Docker images in an Amazon Elastic Container Registry (Amazon ECR) repository. Modify the CodeBuild project runtime configuration to always use the latest image version.
- D. Create a custom AMI containing cached Docker images. In the CodeBuild build, launch an Amazon EC2 instance from the custom AMI.
Correct Answer: A. Store Docker images in an Amazon Elastic Container Registry (Amazon ECR) repository. Enable local Docker layer caching for CodeBuild.
Explanation
In AWS CodeBuild, storing Docker images in Amazon ECR avoids redundant uploads/downloads. Enabling local Docker layer caching allows reuse of existing image layers during builds—reducing build time and network transfer costs, thereby improving performance and lowering cost. Option B’s S3-based caching is unsuitable for Docker’s layered architecture. Option C’s 'latest version' approach undermines caching by forcing re-pull. Option D’s EC2-based solution increases management overhead and startup latency. The combination of ECR and local layer caching best leverages container-specific optimizations while maximizing efficiency.