Docker Container boot up automatically

Source: Internet
Author: User
Tags redis docker run

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.