A container build requires a compiler, but the deployed application requires only the compiled executable and runtime libraries. How should the developer reduce the final image size?
Show the answer
Correct answerB. Use a multi-stage Docker build.
AWhy not this: A smaller build context reduces build input but does not exclude compiler layers from the resulting image.
BWhy this is right: A separate runtime stage can contain the executable and libraries without the compiler or other build tools.
CWhy not this: Compression reduces transfer and storage size but does not exclude unnecessary build tools.
DWhy not this: Lifecycle policies expire stored images; they do not remove build tools from an image.
A multi-stage build compiles the application in one stage and copies only required artifacts into the final runtime stage. Reducing the build context reduces files sent to the builder but does not itself remove compiler layers from the final image.