Bird
0
0

Which of the following Docker Compose service definitions correctly adds a restart policy for production use?

easy📝 Configuration Q12 of 15
Docker - Production Patterns
Which of the following Docker Compose service definitions correctly adds a restart policy for production use?
Arestart: on-failure 5
Brestart: never
Crestart: sometimes
Drestart: always
Step-by-Step Solution
Solution:
  1. Step 1: Review Docker restart policies

    Valid restart policies include 'no', 'always', 'on-failure', and 'unless-stopped'. 'always' restarts the container whenever it stops.
  2. Step 2: Identify correct syntax

    'restart: always' is valid and commonly used in production. 'restart: never' is invalid, 'sometimes' is not a valid policy, and 'on-failure 5' is incorrect syntax (should be 'on-failure:5' for max retries).
  3. Final Answer:

    restart: always -> Option D
  4. Quick Check:

    Valid restart policy = restart: always [OK]
Quick Trick: Use 'restart: always' for reliable container restarts [OK]
Common Mistakes:
  • Using invalid restart policies like 'sometimes'
  • Incorrect syntax for max retry counts
  • Confusing 'never' with 'no'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes