重启策略:

使用在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开机自动启动的更多相关文章

  1. Docker容器开机自动启动

     部署项目服务器时,为了应对停电等情况影响正常web项目的访问,会把Docker容器设置为开机自动启动. 在使用docker run启动容器时,使用--restart参数来设置: # docker r ...

  2. 自动启动docker container

    当系统启动的时候要启动docker container, 可以利用systemctl来实现 比如拿mongodb为例 创建 /usr/lib/systemd/system/docker_mongodb ...

  3. 在docker container中运行docker-compose

    为了保持宿主主机的环境干净,因此将docker-compose安装到一个基于centos7.3的容器之中,因为tianchao屏蔽了amazonaws,最后选择了通过pip方式来安装,这也是官方推荐的 ...

  4. Docker实例开机启动

    部署项目服务器时,为了应对停电等情况影响正常web项目的访问,会把Docker容器设置为开机自动启动. 在使用docker run启动容器时,使用--restart参数来设置: docker run ...

  5. linux启动SSH及开机自动启动

    本文地址 分享提纲: 1.查看是否启动 2. 设置自动启动 1.[查看是否启动] 启动SSH服务 “/etc/init.d/sshd start”.然后用netstat -antulp | grep ...

  6. C#中级-开机自动启动程序

    一.前言 关于C#开机自动启动程序的方法,网上出现比较多的是修改注册表: 1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion ...

  7. 使Docker Container支持运行SWT程序

    1, 下载安装JDK的docker container 我是从这个源下载已经做好的JDK8的container: https://registry.hub.docker.com/u/dockerfil ...

  8. C#.NET Form设置/取消开机自动运行,判断程序是否已经设置成开机自动启动(转载)

    #region//开机自动运行        private void CB_Auto_CheckedChanged(object sender, EventArgs e)        {//CB_ ...

  9. linux系统下设置oracle开机自动启动

    在Linux系统中,安装好oracle数据库服务后,并不像在Windows系统下一样,oracle服务在默认情况下会随时系统的启动自动启动.Linux系统中,是需要用户去手动进行设置,才能实现orac ...

随机推荐

  1. 洛谷 P2278 [HNOI2003]操作系统

    题目传送门 解题思路: 一道没啥思维含量的模拟题,但是个人感觉代码实现不简单,可能是我太弱了,花了我6个小时,3次重写. AC代码: #include<iostream> #include ...

  2. Python笔记_第三篇_面向对象_7.多态

    1. 多态的概念 多态:一种事物的多种形态.其表现形式就是连续的继承关系. 还以人喂食动物的例子.最终目标是人可以喂食任何一种动物.如果人要喂食100多种动物,难道要写100中方法吗?多态就是把属性和 ...

  3. Properties类(一)

    Java中读写资源文件最重要的类是Properties,功能大致如下: 1. 读写Properties文件 2. 读写XML文件 3. 不仅可以读写上述两类文件,还可以读写其它格式文件如txt等,只要 ...

  4. LeetCode——919.完全二叉树插入器

    完全二叉树是每一层(除最后一层外)都是完全填充(即,结点数达到最大)的,并且所有的结点都尽可能地集中在左侧. 设计一个用完全二叉树初始化的数据结构 CBTInserter,它支持以下几种操作: CBT ...

  5. tmp == emg.经典+47

    zw.Y3s3{ttqtf**9q+{xx//up qm+Y3#9t%sfsfqtf+&* hh-Y@15zq&zf51"qt3+x>y ====== 城隍庙 经典景点 ...

  6. 38)PHP,获取数据库数据并在html中显示(晋级5)

    还有一个加了单例模式的,在第52个. 首先是我的文件关系: 我的主php文件是index.php,我的配置文件php是BBB.php  我的数据库操作文件是  b.php    我的html文件是lo ...

  7. fiddler修改请求表单数据

    一.使用出发点:进行测试某个添加编辑功能时候,部分字段前端限制了字段长度或者SQ,特殊字符等等的输入: 但是我们测试验证后端服务器是否处理,这个时候去修改提交请求表单,绕过前端的限制进行测试: 二.使 ...

  8. cesium初探之加载三维模型

    项目需要用到二三维地图切换,本来准备研究ArcGIS js for Web 3d,但考虑到版权的问题,决定试着用cesium来做,于是花了2天时间抱着试试看的心态把cesium从环境配置到加载三维模型 ...

  9. [LC] 110. Balanced Binary Tree

    Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...

  10. 98)PHP,文件类型获取和创建文件夹

    看手册  finfo这个类:This class provides an object oriented interface into the fileinfo functions. 这个$mime_ ...