Question 1
Q1A financial services company is containerizing a legacy Java application using Docker. The security team mandates that the final container image must not include the JDK, build tools like Maven, or any intermediate build artifacts. Furthermore, the image size must be minimized. Which Dockerfile feature is most effective for meeting these requirements?
Show answer & explanation
Correct answer: B
A multi-stage build is the ideal solution. It allows you to use one stage with a full JDK and Maven to compile the application and build the JAR file, and a second, final stage that starts from a minimal JRE base image and copies only the compiled application artifact. This ensures no build tools or intermediate files are present in the final image, directly addressing both security and size requirements.