如何在 Docker Compose V2 中扩展服务? [英] How to extend service in Docker Compose V2?

查看:41
本文介绍了如何在 Docker Compose V2 中扩展服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个不同的项目,ProjectA 依赖于 ProjectB,而后者又依赖于 ProjectC.

I have three different projects, ProjectA depends on ProjectB, which in turn depends on ProjectC.

假设您只想开发 ProjectC,因此我只想在运行时使用一个包含一个容器的设置.

Assume you want to develop only ProjectC, so I want to use a setup with one container only at its runtime.

ProjectB 需要 ProjectC,所以我必须定义一个包含两个图像的 docker-compose.

ProjectB needs ProjectC, so I have to define a docker-compose with two images.

ProjectA 然后又需要 ProjectB 和 ProjectC,所以我担心我必须在每个 docker-compose.yml 文件中重复很多,依赖链越长.

ProjectA then again needs both ProjectB and ProjectC, so I fear I have to either duplicate a lot in the each docker-compose.yml file the longer the dependency chain gets.

我知道我可以在 docker-compose.yml 中链接外部图像,但这意味着更多的手动设置,因为我必须检查每个项目并在每个项目中运行 docker-compose.yml.

I know I can link external images in a docker-compose.yml, yet this means more manual setup, as I have to checkout each project and run docker-compose.yml in each of them.

基本上我想知道如何管理微服务架构的 docker-compose 设置.

Basically I wonder how I can manage a docker-compose setup for a microservice architecture.

没有更好的说法:我可以扩展 docker-compose.yml 文件吗?

For the lack of a better phrase: Can I extend docker-compose.yml files?

推荐答案

下一个版本 (1.5.0) 将支持一种扩展组合的方式(参见 https://github.com/docker/compose/pull/2051).如果您想尝试一下,它现在已经掌握了.

The next release (1.5.0) will support a way to extend a composition (see https://github.com/docker/compose/pull/2051). It is in master now if you want to try it out.

我认为你所描述的非常接近这个提议 https://github.com/docker/compose/issues/318

I think what you're describing is pretty close to this proposal https://github.com/docker/compose/issues/318

这篇关于如何在 Docker Compose V2 中扩展服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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