docker restart_policy on-failure和any之间有什么区别 [英] What's the difference between docker restart_policy on-failure vs any

查看:894
本文介绍了docker restart_policy on-failure和any之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在docker swarm v3文档中,可以使用3种不同的重启策略条件。很明显,条件的作用是什么,但是我想知道失败和<$ c $的区别是什么? c>是任何。

In the docker swarm v3 docs, there are 3 different restart policy conditions that can be used. It's obvious what the none condition does, but I was wondering what the difference between on-failure and any is specifically.

这是

推荐答案

发生故障策略将处理具有非零代码的容器的任何存在时间。 any 策略涵盖了所有其他情况,但是只能在守护程序重新启动时进行处理,具体取决于容器的停止方式(例如,使用 docker故意停止容器停止不会导致立即重启)。

The on-failure policy handles any time a container exist with a non-zero code. The any policy covers any other scenarios, but may only be handled on daemon restart depending on how the container was stopped (e.g. intentionally stopping a container with docker stop does not result in an immediate restart).

有关更多详细信息,请参见此文档: https://docs.docker.com/config/containers/start-containers-automatically/

See this documentation for more details: https://docs.docker.com/config/containers/start-containers-automatically/

注意:我不建议在群集模式下运行的容器重新启动策略。我见过各种情况,例如主机内存不足,群集模式和docker引擎都会尝试重新启动容器,最好让群集模式在另一个主机上重新创建新容器。

Note: I do not recommend a restart policy for containers running within swarm mode. I've seen scenarios, e.g. host out of memory, where both swarm mode and the docker engine attempt to restart the container and it's best to let swarm mode recreate a new container, possibly on another host.

这篇关于docker restart_policy on-failure和any之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆