Kubernetes and Cloud Native Associate (KCNA) — Question 97
What is a best practice to minimize the container image size?
Answer options
- A. Use a DockerFile.
- B. Use multistage builds.
- C. Build images with different tags.
- D. Add a build.sh script.
Correct answer: B
Explanation
Using multistage builds is a best practice because it allows you to separate the build environment from the final runtime environment, drastically reducing the final image size. The other options do not effectively address image size reduction; a DockerFile is necessary but doesn’t minimize size on its own, different tags are for versioning and management, and a build.sh script does not contribute to image size reduction.