Bird
0
0

This docker-compose.yml snippet causes an error:

medium📝 Debug Q7 of 15
Spring Boot - Docker and Deployment
This docker-compose.yml snippet causes an error:
services:
  app:
    image: springboot-app
    ports:
      - 8080:8080
    environment:
      - SPRING_PROFILES_ACTIVE=dev

What is the cause of the error?
AEnvironment variables cannot be set as list
BPort mapping should be a string with quotes
CImage name must include a tag
DPorts key is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check port mapping syntax

    Port mappings must be strings in quotes like "8080:8080". Without quotes, YAML interprets it as a number causing error.
  2. Step 2: Validate environment and image

    Environment variables can be a list, and image name without tag defaults to latest, so no error there.
  3. Final Answer:

    Port mapping should be a string with quotes -> Option B
  4. Quick Check:

    Port mappings require quotes in YAML [OK]
Quick Trick: Always quote port mappings in docker-compose YAML [OK]
Common Mistakes:
  • Leaving port mappings unquoted
  • Thinking environment list is invalid
  • Assuming image tag is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes