AWS Certified DevOps Engineer – Professional (DOP-C02) — Question 321
A DevOps engineer uses AWS CodeBuild to frequently produce software packages. The CodeBuild project builds large Docker images that the DevOps engineer can use across multiple builds.
The DevOps engineer wants to improve build performance and minimize costs.
Which solution will meet these requirements?
Answer options
- A. Store the Docker images in an Amazon Elastic Container Registry (Amazon ECR) repository. Implement a local Docker layer cache for CodeBuild.
- B. Cache the Docker images in an Amazon S3 bucket that is available across multiple build hosts. Expire the cache by using an S3 Lifecycle policy.
- C. Store the Docker images in an Amazon Elastic Container Registry (Amazon ECR) repository. Modify the CodeBuild project runtime configuration to always use the most recent image version.
- D. Create custom AMIs that contain the cached Docker images. In the CodeBuild build, launch Amazon EC2 instances from the custom AMIs.
Correct answer: A
Explanation
Enabling local Docker layer caching in AWS CodeBuild significantly improves build performance and minimizes costs by reusing cached layers on the build host instead of rebuilding or downloading them each time. Amazon Elastic Container Registry (Amazon ECR) is the standard and optimized service for storing and retrieving Docker images in AWS. Other solutions, such as using S3 for layer caching or spinning up custom EC2 instances from AMIs, introduce unnecessary complexity, latency, and increased costs.