on-failure:3. What happens if the container exits with a failure code 1 four times in a row?docker run --restart=on-failure:3 myapp
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.
The always policy restarts the container regardless of exit status, including normal exits.
--restart=unless-stopped. You manually stop it with docker stop. What happens if Docker daemon restarts?The unless-stopped policy restarts containers unless they were manually stopped. After a manual stop, Docker will not restart the container on daemon restart.
You stop the container first, then update the restart policy, then start it again. Finally, inspect to verify the change.
The unless-stopped policy restarts containers on failure or daemon restart, but respects manual stops by not restarting then.
