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 isn't be restarted 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 redis
the container with a restart policy of all so if the container exits, Docker would res Tart 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.
Docker Container boot up automatically