Complete the code to specify the base image for a Java 17 Spring Boot app.
FROM [1]The base image openjdk:17-jdk-slim provides Java 17 needed to run Spring Boot apps.
Complete the code to copy the Spring Boot jar file into the container.
COPY target/[1] /app/app.jarThe built jar file is usually named app.jar in the target folder.
Fix the error in the command to run the Spring Boot jar.
CMD ["java", "-jar", "/app/[1]"]
The jar file name must be exact. app.jar is correct.
Fill both blanks to expose port 8080 and set the working directory to /app.
WORKDIR [1] EXPOSE [2]
The working directory is set to /app where the jar is copied. Port 8080 is the default Spring Boot port.
Fill all three blanks to create a multi-stage Dockerfile: build with Maven, copy jar, and run it.
FROM maven:3.8.7-openjdk-17 AS builder WORKDIR /build COPY [1] . COPY src . RUN mvn clean package -DskipTests FROM openjdk:17-jdk-slim WORKDIR [2] COPY --from=builder /build/target/[3] . CMD ["java", "-jar", "app.jar"]
We copy pom.xml to build the project, set working directory to /app, and copy the built app.jar from the builder stage.