重启策略:

使用在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. 实践一次有趣的sql优化

    课程表 #课程表 create table Course( c_id int PRIMARY KEY, name varchar(10) ) 增加 100 条数据 #增加课程表100条数据 DROP ...

  2. [NOI2014]魔法森林(LCT)

    蒟蒻又发现自己还没写过LCT…… 首先显然按照权值a从小到大排序,维护b的最小生成树.然后直接扫,代价是加入b的最大值,然后动态加边,因为有边权,所以在lct中边应该理解为点.每次连接(u,v)时,若 ...

  3. 12. docker 网络 docker network (docker 网络)

    1. 环境准备 编写 Vagrantfile 为 # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_version "> ...

  4. Java的各类型数据在内存中分配情况详解

    1.      有这样一种说法,如今争锋于IT战场的两大势力,MS一族偏重于底层实现,Java一族偏重于系统架构.说法根据无从考证,但从两大势力各自的社区力量和图书市场已有佳作不难看出,此说法不虚,但 ...

  5. reactor-core

    <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-core&l ...

  6. 搭建公司的React开发环境

    记录公司环境搭建 1.安装VSCODE, 安装网上的推荐各种控件2.安装node, yarn, 会自动添加path3.先初始化npm 全部按回车默认. npm init.  初始化yarn: yarn ...

  7. winform上传文件,利用http,form-data格式上传

    /// <summary> /// 上传文件 /// </summary> /// <param name="url">服务地址</par ...

  8. 图像的手绘效果(Python)

    PIL库,Python Image Library PIL库是一个具有强大图像处理能力的第三方库 在命令行下的安装方法:pip install pillow from PIL import Image ...

  9. 编译原理_P1002

    . 词法分析 1.1 词法记号及属性 词法记号.模式.词法单元 记号名 词法单元列举    模式的非形式描述 if if 字符i,f for for     字符f,o,r relation < ...

  10. Survey sampling

    Survey sampling \(\bullet\)What is survey sampling?(c.f.census survey)(c.f.:参考,查看,来源于拉丁语) \(\bullet\ ...