Restart policy:
Use the--restart parameter to set when using the Docker run.
No-container does not restart
On-failure-container launch status non-0 o'clock restart
Always-restart all the Times
https://docs.docker.com/reference/commandline/cli/#restart-policies Restart Policies
Using the--restart flag on Docker run you can specify a restart policy for how a container should or should not being Restar Ted on Exit.
No-do not restart the container when it exits.
On-failure-restart the container if it exits with a non zero exit status.
Always-always Restart the container regardless of the exit status.
You can also specify the maximum amount of times Docker would try to restart the container when using Theon-failure policy. The default is that Docker would try forever to restart the container.
$ sudo docker run--restart=always Redis
This would run the Redis container with a restart policy of all so if the container exits, Docker would restart it.
$ sudo docker run--restart=on-failure:10 Redis
This would run the Redis container with a restart policy of on-failure and a maximum restart count of 10. If the Redis container exits with a Non-zero exit status more than ten times in a row Docker would abort trying to restart T He container. Providing a maximum restart limit is only valid for the On-failure policy.