码迷,mamicode.com
首页 > 其他好文 > 详细

Docker Container开机自动启动

时间:2015-01-15 10:52:10      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

重启策略:

使用在Docker run的时候使用--restart参数来设置。

no - container不重启

on-failure - container推出状态非0时重启

always - 始终重启

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 be restarted on exit.

no - Do not restart the container when it exits.

on-failure - Restart the container only 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 will try to restart the container when using theon-failure policy. The default is that Docker will try forever to restart the container.

$ sudo docker run --restart=always redis

This will run the redis container with a restart policy of always so that if the container exits, Docker will restart it.

$ sudo docker run --restart=on-failure:10 redis

This will 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 10 times in a row Docker will abort trying to restart the container. Providing a maximum restart limit is only valid for the on-failure policy.

Docker Container开机自动启动

标签:

原文地址:http://www.cnblogs.com/Sloudy/p/4225575.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!