What's the difference between docker restart_policy on-failure vs any

自作多情 提交于 2020-07-30 07:05:08

问题


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.

Here's a picture from the docs:


回答1:


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).

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

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.



来源:https://stackoverflow.com/questions/56554029/whats-the-difference-between-docker-restart-policy-on-failure-vs-any

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!