Recall & Review
beginner
What is a restart policy in Docker?
A restart policy tells Docker when to automatically restart a container if it stops or crashes.
Click to reveal answer
beginner
Name the four main Docker restart policies.
The four main restart policies are: no, on-failure, always, and unless-stopped.
Click to reveal answer
beginner
What does the 'always' restart policy do?
The 'always' policy restarts the container whenever it stops, no matter the exit status, even after Docker daemon restarts.
Click to reveal answer
beginner
How does the 'on-failure' restart policy work?
The 'on-failure' policy restarts the container only if it exits with a non-zero exit code, indicating an error.
Click to reveal answer
intermediate
What is the difference between 'unless-stopped' and 'always' restart policies?
'Unless-stopped' restarts containers unless you manually stop them. 'Always' restarts containers even after manual stops.
Click to reveal answer
Which Docker restart policy restarts a container only if it crashes with an error?
✗ Incorrect
The 'on-failure' policy restarts containers only when they exit with a non-zero error code.
What happens if you set the restart policy to 'no'?
✗ Incorrect
The 'no' policy means Docker will not restart the container automatically.
Which restart policy will restart a container even after Docker daemon restarts?
✗ Incorrect
The 'always' policy restarts containers even after Docker daemon restarts.
If you want a container to restart unless you manually stop it, which policy do you choose?
✗ Incorrect
'Unless-stopped' restarts containers unless you manually stop them.
How do you set a restart policy when running a Docker container?
✗ Incorrect
You use 'docker run --restart= ' to set the restart policy.
Explain the purpose of Docker restart policies and list the main types.
Think about what happens when a container stops or crashes.
You got /2 concepts.
Describe a scenario where you would use the 'on-failure' restart policy instead of 'always'.
Consider when you want to avoid restarting containers that stopped on purpose.
You got /3 concepts.