Bird
0
0

Given this Dockerfile snippet:

medium📝 Command Output Q13 of 15
Spring Boot - Docker and Deployment
Given this Dockerfile snippet:
FROM openjdk:17-jdk-slim
COPY target/app.jar /app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]

What happens when you run the built Docker image?
AThe container runs but does not start the app
BThe container fails because EXPOSE is missing
CThe container runs the Spring Boot app on port 8080
DThe container runs the app but on port 80
Step-by-Step Solution
Solution:
  1. Step 1: Analyze Dockerfile commands

    FROM sets base image with Java 17. COPY adds app.jar. EXPOSE 8080 declares port. ENTRYPOINT runs the jar.
  2. Step 2: Understand container behavior

    When run, container starts Java app listening on port 8080 as declared.
  3. Final Answer:

    The container runs the Spring Boot app on port 8080 -> Option C
  4. Quick Check:

    ENTRYPOINT runs app, EXPOSE 8080 [OK]
Quick Trick: ENTRYPOINT runs app; EXPOSE shows port [OK]
Common Mistakes:
  • Thinking EXPOSE runs the app
  • Assuming default port 80 without config
  • Ignoring ENTRYPOINT command

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes