Bird
0
0

You want to ensure a database schema is initialized before your main app container starts. How would you use an init container to achieve this?

hard📝 Workflow Q8 of 15
Docker - Production Patterns
You want to ensure a database schema is initialized before your main app container starts. How would you use an init container to achieve this?
AUse a sidecar container to run the migration in parallel with the main container
BRun the schema migration inside the main container after it starts
CCreate an init container that runs a schema migration script before the main container starts
DManually run the migration outside the Pod before deployment
Step-by-Step Solution
Solution:
  1. Step 1: Identify init container use case

    Init containers run setup tasks before main container starts, perfect for schema migration.
  2. Step 2: Compare options

    Only Create an init container that runs a schema migration script before the main container starts uses init container to run migration before app starts, ensuring readiness.
  3. Final Answer:

    Create an init container that runs a schema migration script before the main container starts -> Option C
  4. Quick Check:

    Init container runs setup tasks before main app [OK]
Quick Trick: Use init container for pre-start setup tasks like migrations [OK]
Common Mistakes:
  • Running migrations inside main container after start
  • Using sidecar for sequential setup tasks
  • Relying on manual migration outside Pod

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes