Bird
0
0

Consider this docker-compose.yml snippet:

medium📝 Predict Output Q5 of 15
Spring Boot - Docker and Deployment
Consider this docker-compose.yml snippet:
services:
  web:
    image: springboot-web
    ports:
      - "8080:8080"
    environment:
      - SPRING_PROFILES_ACTIVE=prod
  redis:
    image: redis
    ports:
      - "6379:6379"

What environment variable will be available inside the web container?
ASPRING_PROFILES_ACTIVE=dev
BNo environment variables set
CSPRING_PROFILES_ACTIVE=prod
DREDIS_HOST=redis
Step-by-Step Solution
Solution:
  1. Step 1: Locate environment variables in web service

    The web service sets SPRING_PROFILES_ACTIVE=prod under environment.
  2. Step 2: Confirm no other environment variables set

    No other environment variables are defined for web. The redis service does not affect web environment.
  3. Final Answer:

    SPRING_PROFILES_ACTIVE=prod -> Option C
  4. Quick Check:

    environment key sets container variables = prod [OK]
Quick Trick: Environment variables are per service in docker-compose [OK]
Common Mistakes:
  • Assuming default or dev profile is set
  • Confusing environment variables between services
  • Thinking redis variables apply to web

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes