Bird
0
0

How do you correctly specify an init container named init-setup in a Kubernetes Pod YAML?

easy📝 Syntax Q3 of 15
Docker - Production Patterns
How do you correctly specify an init container named init-setup in a Kubernetes Pod YAML?
AinitContainers: - name: init-setup image: alpine command: ['sh', '-c', 'echo Init']
Bcontainers: - name: init-setup image: alpine command: ['sh', '-c', 'echo Init']
CinitContainer: - name: init-setup image: alpine command: ['sh', '-c', 'echo Init']
DinitContainers: name: init-setup image: alpine command: ['sh', '-c', 'echo Init']
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct key

    The correct key is initContainers (plural) at the Pod spec level.
  2. Step 2: Validate YAML structure

    Each init container is an item in the list under initContainers with proper indentation.
  3. Step 3: Check options

    B uses containers which is for main containers; C uses wrong key initContainer; D has wrong indentation and missing list dash.
  4. Final Answer:

    initContainers: - name: init-setup image: alpine command: ['sh', '-c', 'echo Init'] -> Option A
  5. Quick Check:

    Correct key is initContainers with list items [OK]
Quick Trick: Use 'initContainers' key with list of containers [OK]
Common Mistakes:
  • Using singular 'initContainer' instead of 'initContainers'
  • Placing init container under 'containers' section
  • Incorrect YAML indentation or missing list dash

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes