Challenge - 5 Problems
Spring Boot Docker Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of Docker build command
You have this Dockerfile for a Spring Boot app:
What will be the output of
FROM openjdk:17-jdk-slim COPY target/app.jar app.jar ENTRYPOINT ["java", "-jar", "/app.jar"]
What will be the output of
docker build -t springboot-app . if the target/app.jar file is missing?Attempts:
2 left
💡 Hint
Think about what happens if the file to copy does not exist during build.
✗ Incorrect
Docker build fails if a file specified in COPY does not exist. The error shows the missing file path.
❓ Configuration
intermediate2:00remaining
Correct Dockerfile for multi-stage build
Which Dockerfile correctly uses a multi-stage build to compile a Spring Boot app with Maven and produce a minimal final image?
Attempts:
2 left
💡 Hint
Multi-stage builds separate build environment and runtime environment.
✗ Incorrect
Option B uses Maven image to build and then copies only the jar to a slim image for runtime, reducing image size.
❓ Troubleshoot
advanced2:00remaining
Why does the Spring Boot app fail to start in Docker?
You built a Docker image for your Spring Boot app but when running the container, it exits immediately with no logs. The Dockerfile is:
What is the most likely cause?
FROM openjdk:17-jdk-slim COPY target/app.jar app.jar ENTRYPOINT java -jar app.jar
What is the most likely cause?
Attempts:
2 left
💡 Hint
How Docker interprets ENTRYPOINT differs between string and array syntax.
✗ Incorrect
ENTRYPOINT as a string runs in shell form, which can cause the process to not stay in foreground. Using exec form (array) is recommended.
🔀 Workflow
advanced2:00remaining
Order of steps to build and run Spring Boot Docker container
Put these steps in the correct order to build and run a Spring Boot app Docker container:
1. Run the container with
2. Write the Dockerfile
3. Build the jar with Maven
4. Build the Docker image with
1. Run the container with
docker run2. Write the Dockerfile
3. Build the jar with Maven
4. Build the Docker image with
docker buildAttempts:
2 left
💡 Hint
Think about what you need before building the image and running the container.
✗ Incorrect
You first write the Dockerfile, then build the jar, then build the image, then run the container.
✅ Best Practice
expert2:00remaining
Best practice for reducing Spring Boot Docker image size
Which option is the best practice to reduce the size of a Spring Boot Docker image?
Attempts:
2 left
💡 Hint
Think about separating build and runtime environments.
✗ Incorrect
Multi-stage builds allow compiling in a full environment and then copying only the needed jar to a small runtime image, reducing size.