重启策略:

使用在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. 01.Homebrew

    1.homebrew 的安装 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/ ...

  2. C++类的访问控制关键字

    public:修饰的成员变量和函数,可以在类的内部和类的外部被访问. private:修饰的成员变量和函数,只能在类的内部被访问,不能在类的外部被访问. protected:修饰的成员变量和函数,只能 ...

  3. Vue插件配置和 后台交互

    Vue插件配置和 后台交互 一.全局配置静态文件(csss, js..) 1.1 全局配置css文件 创建css文件 在main.js配置css文件 // 配置全局css样式 // 方式一 impor ...

  4. 使用python列出目录下的所有文件

    https://stackoverflow.com/questions/3964681/find-all-files-in-a-directory-with-extension-txt-in-pyth ...

  5. druid+mybaits简单集成

    在前面的文章中,我们对springboot开发中一些常用的框架进行了集成,但是发现还是存在一些问题,比如druid还需要比较长的固有配置,实际上druid官方是提供了相关的starters包的,内部采 ...

  6. diary-2019.9.16

    It has been observed by various scientists and nutritionists that it is better to have smaller and a ...

  7. redis 的雪崩和穿透?

    https://blog.csdn.net/Aria_Miazzy/article/details/88066975

  8. P2448 无尽的生命(树状数组+离散化)

    题目描述 逝者如斯夫,不舍昼夜! 叶良辰认为,他的寿命是无限长的,而且每天都会进步. 叶良辰的生命的第一天,他有1点能力值.第二天,有2点.第n天,就有n点.也就是S[i]=i 但是调皮的小A使用时光 ...

  9. PAT甲级——1042 Shuffling Machine

    1042 Shuffling Machine Shuffling is a procedure used to randomize a deck of playing cards. Because s ...

  10. locate及find查找命令

    在文件系统上查找符合条件的文件:       实现工具:locate,find locate:       依赖于事先构建好的索引库:       系统自动实现(周期性任务):       手动更新数 ...