0
0
Spring Bootframework~10 mins

Dockerfile for Spring Boot in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the base image for a Java 17 Spring Boot app.

Spring Boot
FROM [1]
Drag options to blanks, or click blank then click option'
Aubuntu:20.04
Bpython:3.9
Copenjdk:17-jdk-slim
Dnode:18-alpine
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a base image without Java.
Using an older Java version image.
2fill in blank
medium

Complete the code to copy the Spring Boot jar file into the container.

Spring Boot
COPY target/[1] /app/app.jar
Drag options to blanks, or click blank then click option'
Aapplication.properties
Bapp.jar
CDockerfile
Dpom.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Copying configuration files instead of the jar.
Copying the Dockerfile by mistake.
3fill in blank
hard

Fix the error in the command to run the Spring Boot jar.

Spring Boot
CMD ["java", "-jar", "/app/[1]"]
Drag options to blanks, or click blank then click option'
Aapp.jarr
Bapp
Capp.jar/
Dapp.jar
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the jar file name.
Adding a slash after the jar file name.
4fill in blank
hard

Fill both blanks to expose port 8080 and set the working directory to /app.

Spring Boot
WORKDIR [1]
EXPOSE [2]
Drag options to blanks, or click blank then click option'
A/app
B8080
C/usr/src/app
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Exposing the wrong port like 80.
Setting working directory to a different folder.
5fill in blank
hard

Fill all three blanks to create a multi-stage Dockerfile: build with Maven, copy jar, and run it.

Spring Boot
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"]
Drag options to blanks, or click blank then click option'
Apom.xml
B/app
Capp.jar
Dsrc
Attempts:
3 left
💡 Hint
Common Mistakes
Copying source code folder instead of pom.xml.
Setting wrong working directory in final stage.
Copying wrong jar file name.