0
0
Dockerdevops~20 mins

Restart policies in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Restart Policy Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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
ADocker never restarts the container because the failure count is exceeded before starting.
BDocker restarts the container indefinitely regardless of failure count.
CDocker restarts the container only the first 3 times it fails, then stops trying after the 4th failure.
DDocker restarts the container exactly 4 times, including the initial run.
Attempts:
2 left
💡 Hint
Think about how the number after 'on-failure' limits restart attempts.
🧠 Conceptual
intermediate
1: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?
Aon-failure
Balways
Cunless-stopped
Dno
Attempts:
2 left
💡 Hint
Consider which policy ignores exit status.
Troubleshoot
advanced
2: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?
AThe container does not restart because it was manually stopped.
BThe container restarts only if Docker daemon was restarted manually.
CThe container restarts only if it exited with failure.
DThe container restarts because 'unless-stopped' ignores manual stops.
Attempts:
2 left
💡 Hint
Think about how 'unless-stopped' treats manual stops.
🔀 Workflow
advanced
2: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?
A2,3,1,4
B1,2,3,4
C1,4,2,3
D2,1,3,4
Attempts:
2 left
💡 Hint
You must stop the container before updating restart policy.
Best Practice
expert
3: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?
Aunless-stopped
Balways
Cno
Don-failure
Attempts:
2 left
💡 Hint
Consider manual stops and automatic restarts on daemon restart.