When setting up a containerized deployment of an AI model using Docker, what is the primary purpose of a 'multi-stage build'?
Multi-stage builds let earlier stages compile dependencies and artefacts, then copy only the runtime essentials into a slim final stage. This directly satisfies the stem's containerised AI deployment constraint: the shipped image carries no build toolchain, cutting both image size and exploitable attack surface.
Why this answer
The primary purpose of a multi-stage build in Docker is to reduce the final image size and attack surface by separating the build environment from the runtime environment. Build tools, compilers, and intermediate dependencies are used in an early stage but are not copied into the final image, leaving only the necessary runtime artifacts. This results in a leaner, more secure production image.
Exam trap
AAIA often tests the distinction between build-time optimizations and runtime orchestration features, so the trap is selecting answers about scaling or running multiple models when the question is specifically about Docker image construction.
How to eliminate wrong answers
Option A is wrong because running multiple versions of a model simultaneously is an orchestration/scaling concern, not the purpose of a multi-stage build. Option B is wrong because training a model during container startup is inefficient and unrelated to multi-stage builds, which are about image construction, not runtime training. Option C is wrong because automatic scaling based on traffic is a feature of orchestration platforms like Kubernetes, not Docker multi-stage builds.