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

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

问题描述

docker-compose 2.1 提供了一个很好的特性来指定一个 conditiondepends_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 不再支持depends_on 的条件形式.

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天全站免登陆