0
0
Dockerdevops~5 mins

Restart policies in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aalways
Bon-failure
Cno
Dunless-stopped
What happens if you set the restart policy to 'no'?
ADocker never restarts the container automatically
BDocker always restarts the container
CDocker restarts only on failure
DDocker restarts unless manually stopped
Which restart policy will restart a container even after Docker daemon restarts?
Ano
Bon-failure
Calways
Dnone
If you want a container to restart unless you manually stop it, which policy do you choose?
Aunless-stopped
Balways
Con-failure
Dno
How do you set a restart policy when running a Docker container?
Adocker create --restart-policy=<policy> <image>
Bdocker start --restart=<policy> <container>
Cdocker restart --policy=<policy> <container>
Ddocker run --restart=<policy> <image>
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.