Bird
0
0

You want to share a configuration file from your host machine with a Spring Boot service in docker-compose. Which is the correct way to do this?

hard📝 Conceptual Q9 of 15
Spring Boot - Docker and Deployment
You want to share a configuration file from your host machine with a Spring Boot service in docker-compose. Which is the correct way to do this?
AUse the <code>depends_on</code> key to link the file
BUse the <code>volumes</code> key to mount the file into the container
CUse the <code>environment</code> key to pass the file path
DUse the <code>ports</code> key to expose the file
Step-by-Step Solution
Solution:
  1. Step 1: Understand file sharing in docker-compose

    To share files, volumes mounts host files or directories into containers.
  2. Step 2: Exclude other keys

    environment passes variables, depends_on manages service order, and ports exposes network ports, none share files.
  3. Final Answer:

    Use the volumes key to mount the file into the container -> Option B
  4. Quick Check:

    volumes = share files/directories [OK]
Quick Trick: Use volumes to share files between host and container [OK]
Common Mistakes:
  • Trying to pass files via environment variables
  • Confusing depends_on with file sharing
  • Using ports to share files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes