在docker-compose版本3中,depends_on条件形式的替代方案是什么? [英] What is the alternative to condition form of depends_on in docker-compose Version 3?

查看:1131
本文介绍了在docker-compose版本3中,depends_on条件形式的替代方案是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

docker-compose 2.1提供了一个不错的功能,可以使用 depends_on 来指定条件。当前的docker-compose文档指出:

docker-compose 2.1 offers the nice feature to specify a condition with depends_on. The current docker-compose documentation states:


版本3不再支持条件形式的条件。

Version 3 no longer supports the condition form of depends_on.

不幸的是,文档没有解释,为什么删除了条件表单,并且对于如何使用V3向上实现该行为缺乏具体的建议。

Unfortunately the documentation does not explain, why the condition form was removed and is lacking any specific recommondation on how to implement that behaviour using V3 upwards.

推荐答案

与在compose中指定容器依赖项有所不同。它们仅在启动时有效,而在运行时重新启动从属容器时无效。而是,每个容器都应包括在断开连接后重试重新连接到相关服务的机制。许多用于连接数据库或REST API服务的库都具有可配置的内置重试。我会调查一下。无论如何,生产代码都需要它。

There's been a move away from specifying container dependencies in compose. They're only valid at startup time and don't work when dependent containers are restarted at run time. Instead, each container should include mechanism to retry to reconnect to dependent services when the connection is dropped. Many libraries to connect to databases or REST API services have configurable built-in retries. I'd look into that. It is needed for production code anyway.

这篇关于在docker-compose版本3中,depends_on条件形式的替代方案是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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