Challenge - 5 Problems
Restart Policy Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the effect of the restart policy 'on-failure:3'?
You run a Docker container with the restart policy set as
on-failure:3. What happens if the container exits with a failure code 1 four times in a row?Docker
docker run --restart=on-failure:3 myapp
Attempts:
2 left
💡 Hint
Think about how the number after 'on-failure' limits restart attempts.
✗ Incorrect
The on-failure:3 policy tells Docker to restart the container only if it exits with a failure code, and to do this at most 3 times. After the 3rd restart, Docker stops trying.
🧠 Conceptual
intermediate1:30remaining
Which restart policy restarts a container always, even if it exits normally?
You want a Docker container to restart no matter how it stops, including normal exits. Which restart policy should you use?
Attempts:
2 left
💡 Hint
Consider which policy ignores exit status.
✗ Incorrect
The always policy restarts the container regardless of exit status, including normal exits.
❓ Troubleshoot
advanced2:00remaining
Why does a container with restart policy 'unless-stopped' not restart after a manual stop?
You set a container with
--restart=unless-stopped. You manually stop it with docker stop. What happens if Docker daemon restarts?Attempts:
2 left
💡 Hint
Think about how 'unless-stopped' treats manual stops.
✗ Incorrect
The unless-stopped policy restarts containers unless they were manually stopped. After a manual stop, Docker will not restart the container on daemon restart.
🔀 Workflow
advanced2:30remaining
Order the steps to set a restart policy on an existing container
You have a running container named 'webapp'. You want to set its restart policy to 'always'. What is the correct order of commands?
Attempts:
2 left
💡 Hint
You must stop the container before updating restart policy.
✗ Incorrect
You stop the container first, then update the restart policy, then start it again. Finally, inspect to verify the change.
✅ Best Practice
expert3:00remaining
Which restart policy is best for a critical service that must always run unless explicitly stopped?
You deploy a critical service in Docker that must restart automatically on failure or daemon restart, but should not restart if you manually stop it. Which restart policy fits best?
Attempts:
2 left
💡 Hint
Consider manual stops and automatic restarts on daemon restart.
✗ Incorrect
The unless-stopped policy restarts containers on failure or daemon restart, but respects manual stops by not restarting then.