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:
Step 1: Review Docker restart policies
Valid restart policies include 'no', 'always', 'on-failure', and 'unless-stopped'. 'always' restarts the container whenever it stops.
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).
Final Answer:
restart: always -> Option D
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'
Master "Production Patterns" in Docker
9 interactive learning modes - each teaches the same concept differently